Answer the question
In order to leave comments, you need to log in
Nginx - the duplicate "https" variable. What to do with it?
Good afternoon!
Faced such a problem - set up a load balancer on nginx.
On the old server - works + works on some servers identical in software (on which the php application is running). And on new load balancers, it throws the error "the duplicate "https" variable in /etc/nginx/sites-enabled/dc_proxy:56"
This is the configuration:
upstream dutybalancer {
#ip_hash means - the same visitor goes to the same server
ip_hash;
#least_conn;
server application1;
server application2;
}
upstream dutybalancer_ssl {
#ip_hash means - the same visitor goes to the same server
ip_hash;
#least_conn;
server application1:443;
server application2:443;
}
server {
listen *:443 ssl; # port https
listen *:80; # port http
if ($server_port = 443) { set $https on;}
if ($server_port = 80) { set $https off; }
... тут немного сертификатов
location / {
if ($server_port = 443) { proxy_pass https://dutybalancer_ssl; }
if ($server_port = 80) { proxy_pass http://dutybalancer; }
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Answer the question
In order to leave comments, you need to log in
I don't understand why you are redefining the built-in variable?
nginx.org/en/docs/http/ngx_http_core_module.html#v... The
meaning of going to different balancers is also incomprehensible, usually they are limited to passing an HTTP header likeproxy_set_header X-HTTPS $https;
Try splitting the configuration into two servers:
server {
listen *:80; # port http
set $https off;
location / {
proxy_pass http://dutybalancer;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen *:443 ssl; # port https
set $https on;
... тут немного сертификатов
location / {
proxy_pass https://dutybalancer_ssl;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question