problem description
the first nginx server is configured with reverse proxy to a kibana server, and a second nginx direction proxy to the first nginx server. It is found that the first nginx cannot be accessed normally on the second nginx.
related codes
configuration of the first nginx reverse proxy
server_name: ng1
location / {
proxy_pass http://kibana_server:8009;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
configuration of the second nginx reverse proxy
server_name: ng2
location ^~ /kb/ {
proxy_redirect off;
proxy_pass http://ng1:80/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 600;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
}
expect the second nginx to access the kibana server as well as the first nginx.
now the error is: the browser accesses http://ng2/kb/ and the result url becomes http://ng2/app/kibana 404
.