Is there a way to redirect https:// requests to http:// by adding a rule in the domain's vhost file? I'm using NGINX.
+3
A:
Why is something like that useful? At first look I wasn't sure if it could be done. But it presented an interesting question.
You might try putting a redirect statement in your config file and restarting your server. Two possibilities might happen:
- The server will issue the redirect - what you seem to want.
- The server will first do the https exchange, and THEN issue the redirect, in which case, what's the point?
Will add more if I come up with something more concrete.
UPDATE: (couple of hours later) You could try this. You need to put this in your nginx.conf file -
server {
listen 443;
server_name _ *;
rewrite ^(.*) http://$host$1 permanent;
}
Sends a permanent redirect to the client. I am assuming you are using port 443 (default) for https.
server {
listen 80;
server_name _ *;
...
}
Add this so that your normal http requests on port 80 are undisturbed.
MovieYoda
2010-10-12 14:39:38
+1
A:
location / {
if ($scheme = https) {
rewrite ^(.*)? http://$http_host$1 permanent;
}
}
Daniel Hai
2010-10-12 16:55:05
might need to add a location flag that is more encompassing than / if you want to ensure everything is matched. But the answer with server is probably best to be honest. How are you handling vhosts anyways?
Daniel Hai
2010-10-12 16:57:36
A:
The only simple rule is already explained on the post above me:
server {
listen ip:443;
server_name www.example.com;
rewrite ^(.*) http://$host$1 permanent;
}
or if you want it to be a single line:
server { listen ip:443; server_name www.example.com; rewrite ^(.*) http://$host$1 permanent;}
Maarten
2010-10-15 20:02:45