For example, I have a website under the domain example.com
. In that site, I have a page like this example.com/hello
. Now I need to point my second domain hello.com
to that page example.com/hello
. It should not be a re-direct. The visitor should stay in hello.com
but see the content from the page example.com/hello
. Is this possible? Can we do it in dns or in nginx?
The access log after using proxy pass :
123.231.120.120 - - [10/Mar/2016:19:53:18 +0530] "GET / HTTP/1.1" 200 1598 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
123.231.120.120 - - [10/Mar/2016:19:53:18 +0530] "GET /a4e1020a9f19bd46f895c136e8e9ecb839666e7b.js?meteor_js_resource=true HTTP/1.1" 404 44 "http://swimamerica.lk/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.$
123.231.120.120 - - [10/Mar/2016:19:53:18 +0530] "GET /9b342ac50483cb063b76a0b64df1e2d913a82675.css?meteor_css_resource=true HTTP/1.1" 200 73 "http://swimamerica.lk/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.262$
123.231.120.120 - - [10/Mar/2016:19:53:18 +0530] "GET /images/favicons/favicon-16x16.png HTTP/1.1" 200 1556 "http://swimamerica.lk/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
123.231.120.120 - - [10/Mar/2016:19:53:19 +0530] "GET /images/favicons/favicon-96x96.png HTTP/1.1" 200 1556 "http://swimamerica.lk/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
123.231.120.120 - - [10/Mar/2016:19:53:19 +0530] "GET /images/favicons/favicon-32x32.png HTTP/1.1" 200 1556 "http://swimamerica.lk/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
123.231.120.120 - - [10/Mar/2016:19:53:19 +0530] "GET /images/favicons/android-icon-192x192.png HTTP/1.1" 200 1556 "http://swimamerica.lk/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
After moving to another web hosting provider, you need to point your domain to a new host to make your site accessible. Luckily, you can easily do that by changing the domain's nameservers. Simply get the details of your new nameservers, copy it to the domain's DNS settings, and wait for the DNS to propagate.
Type: Permanent. Choose the domain to redirect from the pulldown menu. If you only wish to redirect a specific page, enter it into the box to the right of the slash (example: mysite.com/page1.html) In Redirect to, enter the destination address.
Click the URL Redirects tab. In the upper right, click Add URL redirect. In the right panel, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.
You can use proxy_pass
directive. Just create a new server associated with the domain hello.com
and then for location = /
set proxy_pass
equals to http://example.com/hello
:
server {
server_name hello.com;
# ...
location = / {
proxy_pass http://example.com/hello/;
}
# serve static content (ugly way)
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|rss|txt)$ {
proxy_pass http://example.com/hello/$uri$is_args$args;
}
# serve static content (better way,
# but requires collection all assets under the common root)
location ~ /static/ {
proxy_pass http://example.com/static/;
}
}
UPD: Here is an exact solution for your situation:
server {
server_name swimamerica.lk;
location = / {
proxy_pass http://killerwhales.lk/swimamerica;
}
# serve static content (ugly way) - added woff and woff2 extentions
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|rss|txt|woff|woff2)$ {
proxy_pass http://killerwhales.lk$uri$is_args$args;
}
# added location for web sockets
location ~* sockjs {
proxy_pass http://killerwhales.lk$uri$is_args$args;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With