G
G
gremlintv22018-03-19 12:11:56
Nginx
gremlintv2, 2018-03-19 12:11:56

Why might nginx redirect not work?

server {
listen 111.111.111.111:443 ssl http2;
server_name site1.com;
ssl_certificate /etc/letsencrypt/live/site1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site1.com/privkey.pem;
location / {
return 301 https://site2.com$request_uri;
}
location /secure/ {
try_files $uri =404;
}
}
server {
listen 111.111.111.111:80;
server_name site1.com;
return 301 http://site2.com$request_uri;
}

When accessing https://site1.com
, it redirects to http://site2.com,
but it needs to redirect to https://site2.com

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Mukovoz, 2018-03-19
@castomi

If you write site1.com in the address bar, it will redirect to site2.com.
If you write https://site1.com in the address bar, it will redirect to https://site2.com.
All this is written in your rules. Learn to read them, and read the documentation, and not copy the configs from the left sites, then there will be no such questions)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question