I'm new to nginx and am trying to figure out an issue with redirection. I'm trying to redirect a website from a host running a web application to another domain. That part I've done but I'm looking to mask it. When it redirects, I don't want the user to know they've gone to another domain.
I've substituted the domain names for privacy of my client. But, they are on a Linode at test.com that's running a web application that's at sub.test.com. All I want is for any user visiting test.com to be redirected to a temporary site hosted on other.com but without exposing the domain.
Previously, someone had shown me how to do it but it was a long time ago and I no longer have the information to reference. Can someone help me out? I don't want to expose the domain of the testing environment.
server {
listen 80;
server_name www.test.com test.com www.test.net test.net;
rewrite ^ http://other.com/sub redirect;
location / {
root /srv/http/www.test.com;
index index.html;
}
}
You can't do that with redirect, cause redirect is actually like telling the browser where to fetch page from, so you can't obscure the real location.
I guess what you need is proxying, e.g. a client requests some document from your server (test.com), then your server fetches the document from some other server (other.com) and returns that document to a client as if it was generated on test.com - it that case a client won't be able to determine where actually the document is originating from.
This can be done with:
server_name test.com;
location / {
proxy_pass http://other.com;
}
if you want the redirect to not change the user-visible domain name then you need to change it from a 301 to a 302 by changing your rewrite as follows:
rewrite ^ http://other.com/sub redirect;
Related
I'm sorry for this stupid question, but I'm very new to hosting and domain things and I need help. My Website PrepareHOW.org is not accessible with PrepareHOW.org but can be visited via Preparehow.org/index.html How can I remove this error so that people can access my website with my domain url.
If you using nginx as frontend of webserver just check config for this domain.
This lines need to add to config:
root /path/to/site/root/folder;
location / {
try_files $uri /index.html$is_args$args;
}
Then restart nginx and check result!
I have an open shift account and I created an application a little while ago for which I didn't add a domain. Now i am trying to add the domain its not working correctly.
The domain is www.quantumfreedom.com. There is a CNAME in place for both www and * pointing to the application on openshift. I have submitted a ticket on GoDaddy and with my other domain provider and they both say it's a hosting issue and not a domain or DNS issue.
The full message reads as follows:
The page isn’t redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept
cookies.
This is not the only domain I have an issue with before with open shift.
Current CNAME record for www.quantumfreedom.com looks like this:
;QUESTION
www.quantumfreedom.com. IN CNAME
;ANSWER
www.quantumfreedom.com. 3548 IN CNAME vitscript-james1vince.rhcloud.com.
If http://vitscript-james1vince.rhcloud.com is the site you want to show to the users who type http://www.quantumfreedom.com in their address bar, then as far as DNS is concerned, there is nothing more you can or should do, users will be directed to the correct IP address.
Now you need to make sure that once the request for www.quantumfreedom.com arrives at your http server, the server responds with correct content. At the moment that is not the case, if you try from command line:
curl -v http://www.quantumfreedom.com/
Notice these two lines in response:
< HTTP/1.1 301 Moved Permanently
< Location: http://www.quantumfreedom.com/
This means that webserver is redirecting the client back to the same url, causing an infinite loop, resulting in browser error:
ERR_TOO_MANY_REDIRECTS
(or similar, depending on the browser)
This redirect can com from either webserver settings (Apache .conf or .htaccess files) or even application itself, so those would be the places to look next.
Using this tutorial
http://rainbow-six3.com/plesknginx/ i am trying to redirect my name.com to ip:8080 , after that setup if i acces through name.con i get an redirection loop... is there any other service to redirect? Had a lot of problems with nginx.
I want to redirect name.com to an tomcat7 application wich uses ip:8080 to get executed. Tomcat is already an headache...
Neither this helped me:
Tomcat base URL redirection
It outputs webpage not available on link: http://name.com/index.jsp
Mind the words. 'Redirecting' != 'Proying'. You redirect through 301 or 302 to a publicly directly accessible resource, while you proxy to a backend, not supposed to be directly accessed.
The minimal configuration to proxy any name.com/<whatever> request to <ip>:8080/<whatever> is:
server {
listen 80;
server_name name.com;
location / {
proxy_pass $scheme://<ip>:8080;
}
}
hi i have nginx server and other webserver which i want to hide from public direct access. but when i try to access that server on root i send redirect response to client to url like this: server/test/spring/main. when i try to access it from nginx server i get the server url redirect instead nginx url.
example:
my-nginx.com
my-server.com
if i want to access myserver.com/test/spring/main from nginx server i guess i have to access my-nginx.com/test/spring/main but when i do that i get redirect to url myserver.com...
my config:
upstream my-server {
server my-server.com;
}
server {
listen 80;
server_name my-nginx;
location / {
proxy_pass http://my-server/;
}
}
the other think is when i access the root page on my-server.com i redirect the client to "https://my-server.com/test/spring/main".
Why i'm redirect from my-nginx.com url to my-server.com?
This configuration seems do not have big problem, and I also use proxy_pass to access other domain in our production environment, and do not redirect.
You should be care of the last '/' in "http://my-server/", usint "http://my-server" instead, or just using "http://my-server.com" with no upstream.
The behavior with '/' or with not '/' is a little different.
To replace a legacy web site, a client has pointed their DNS at my server where a new version of the website exists.
However they still serve http://support.example.com from their own server.
I have noticed that non-www requests, e.g. http://example.com still point to their own server, therefore show the old web site.
How can I point non-www requests, http://example.com at my server without breaking the functionality of their 'support' sub-domain?
The client's server is a Microsoft server, mine is Linux/Apache
Edit: Changing the DNS 'A' record will not break the existing sub-domain
I know I could add an index.html page to the front of the old site, but if it was ever deleted the page requests would cease to work
I can't use mod-rewrite because I don't have access to their web server files
PROPOSED SOLUTION:
On the client DNS, create an A
record for:
support.example.com – IP of the client's server
example.com – IP of my server
www.example.com - IP of my server
No need for any DNS changes on my server regarding this domain
Changing the A record for example.com won't affect the A record for support.example.com.