I am trying to redirect http traffic to https (classic case, I know).
But, my issue is that before we moved on to serving over https, we had the site serving on http://poubelle.net:8080/
. The problem is that even though we are now asking all users to use https://poubelle.net/
, every now and then a user will type httpS://poubelle.net:8080
and that fails.
I have tried many combinations and solutions, including erro_page 497
type solutions, but I need help to solve this.
Below is my current simplified config... what do I need to add to make it so that:
- http://poubelle.net/
- http://poubelle.net:8080/
- httpS://poubelle.net:8080/
- and of course https://poubelle.net/
all redirect to https://poubelle.net/ ? (config below works for cases 1, 2 and 4 but not 3)
server {
listen 8080;
server_name ${SERVER_NAME};
return 301 https://$host$request_uri;
}
server {
listen 80 default_server;
server_name ${SERVER_NAME};
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name ${SERVER_NAME};
ssl_certificate .../fullchain.pem;
ssl_certificate_key .../privkey.pem;
ssl_trusted_certificate .../cert.pem;
...
location / {
proxy_pass http://127.0.0.1:8081;
...
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /data/nginx/html/poubelle.net;
...
}
}
Aucun commentaire:
Enregistrer un commentaire