I have a nginx configuration like below:
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name www.example.com;
location @publicsite {
resolver 8.8.8.8;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection close;
proxy_pass https://public-site.com$request_uri;
}
location / {
try_files $uri @publicsite;
}
//other locations...
}
With this configuration, when I try to access www.example.com/pricing/
it works like expected. But when I try to access www.example.com/pricing
it works like https://public-site.com/pricing/
.
Is there a way to escape from this real-domain redirection?
Output:
www.example.com/pricing/ => www.example.com/pricing/
www.example.com/pricing => https://public-site.com/pricing/
Expected:
www.example.com/pricing/ => www.example.com/pricing/
www.example.com/pricing => www.example.com/pricing/
CodePudding user response:
fixed my problem with
proxy_set_header Host public-site.com;