@giovanny.lueilwitz
To redirect a URL with ProxyPass using Nginx, you can use the following configuration in your Nginx server block:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
server {
listen 80;
server_name example.com;
location /old-url {
proxy_pass http://new-url;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http://new-url https://example.com;
error_page 301 302 = @permanently-redirect;
}
location @permanently-redirect {
return 301 https://example.com/new-url;
}
}
|
In this configuration: