私もこれに遭遇し、nginx構成のproxy_passディレクティブの直後にproxy_redirectディレクティブを使用して修正できました。
proxy_redirect http://example.com:8080/ http://example.com/
これは私の完全なnginx構成です(私の場合、Apacheはポート81にあり、2つのサイトをホストしています。単一の一般的なものを追加する方法がわからないため、2つのサイト固有のproxy_redirect行を追加しました)。
server {
listen 80;
access_log /var/log/nginx/apache-proxy.access.log;
location / {
proxy_pass http://localhost:81;
#fix for apache redirects that include the port number
proxy_redirect http://nfriedly.com:81/ http://nfriedly.com/;
proxy_redirect http://misticflame.com:81/ http://misticflame.com/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 6000;
proxy_send_timeout 6000;
proxy_read_timeout 6000;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
send_timeout 6000;
proxy_buffering off;
proxy_next_upstream error;
}
}
注:これは、5年以上前のnginxの1.0より前のバージョン用でした。現在のバージョンのproxy_redirectのドキュメントは次のとおりです:http ://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect