简体   繁体   中英

DNS hosting public and web application on different hosts

Here is my setup.

  1. Public site hosted by squarespace.com (www.example-domain.com)
  2. Web application (AWS EC2/ELB), i would like to be available via the same domain. (my.example-domain.com)
  3. Custom profile pages available as www.example-domain.com/username

My question is how can i setup the DNS to achieve this? If can't do it just through DNS, any suggestions? The problem i am facing is that if squarespace.com is handling the www.example-domain.com traffic how can i have it only partially handle it for certain urls. Maybe i am going about this in the wrong was all together though.

The two first are ok. As you mention, (1) is not compatible with (3) for a pure DNS config as www of example-domain.com has to be configured to a single end-point.

Some ideas of non-DNS workaround:

  • Having the squarespace.com domain on sqsp.example-domain.com and configure your www domain to a custom web server on which you configure the root ( / ) to redirect (HTTP 300) to sqsp.example-domain.com . It will be quite transparent for the user, except in his browser address.
  • The same but setting on / a full page HTML iframe containing sqsp.example-domain.com .

The iframe approach is a "less clean", Google the solutions to build your opinion.

EDIT: As @mike-ryan mentioned, there is the proxy solution as well where you configure you web server to request another server to get the content to return to your user. If you are already using AWS, a smart way to do this is to use CloudFront: you can setup CloudFront to proxy one server on one URL and proxy another server on other URL. Actually, this is maybe the faster to way to implement you need. Of course, a proxy is one more "hop", so it may add more delay.

If you really want to have content served from different servers while only using a single domain name, you'll need to set up a proxy server to handle the request routing for you. I am assuming your custom profile pages must be served from your EC2 instance.

Nginx will receive all requests, and will then decide whether they should be sent to Square Space or your web app. Requests will be reverse proxied to Square Space or to your app, depending on the URL.

This is similar to @smad's answer, except it will all be invisible to the users which IMHO is better than redirecting the user to a new domain name.

Example steps:

  • Set up an Nginx server, create two virtual hosts - one for my.example.com, and one for www.example.com
  • Create two upstreams in your Nginx config - one for Square Space, and one for your app
  • Configure the www.example.com virtual host to reverse proxy connections to the Square Space upstream, if the URL is "/". Otherwise, traffic should be proxied to your app upstream [0]
  • Configure the my.example.com virtual host to proxy all traffic to your app upstream

[0] how to reverse proxy via nginx a specific url?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM