proxy_pass を使用してリクエストを複数のバックエンド サービスに転送するように Nginx を設定しようとしています。
末尾にスラッシュがないページ上のリンクにはhttps://
先頭にスラッシュがありますが、末尾にスラッシュがある http リクエストにリダイレクトされ、接続が拒否されます。これらのサービスは https 経由でのみ利用できるようにしたいと考えています。
リンクが長すぎる場合はhttps://example.com/internal/errorlogs
ブラウザで読み込まhttps://example.com/internal/errorlogs
れるとError Code 10061: Connection refused
、(にリダイレクトされますhttp://example.com/internal/errorlogs/
)
手動でトライアルスラッシュを追加するとhttps://example.com/internal/errorlogs/
ロードされます
proxy.confのproxypathとlocationに様々な末尾のスラッシュを追加してみましたが効果はありませんでした。また、server_name_in_redirect off;
これはnginxの複数のアプリで発生し、Apacheリバースプロキシでも機能します。
設定ファイル;
プロキシ.conf
location /internal {
proxy_pass http://localhost:8081/internal;
include proxy.inc;
}
.... more entries ....
サイト対応/メイン
server {
listen 443;
server_name example.com;
server_name_in_redirect off;
include proxy.conf;
ssl on;
}
プロキシ株式会社
proxy_connect_timeout 59s;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_pass_header Set-Cookie;
proxy_redirect off;
proxy_hide_header Vary;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header Accept-Encoding '';
proxy_ignore_headers Cache-Control Expires;
proxy_set_header Referer $http_referer;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-Proto https;
curl 出力
-$ curl -I -k https://example.com/internal/errorlogs/
HTTP/1.1 200 OK
Server: nginx/1.0.5
Date: Thu, 24 Nov 2011 23:32:07 GMT
Content-Type: text/html;charset=utf-8
Connection: keep-alive
Content-Length: 14327
-$ curl -I -k https://example.com/internal/errorlogs
HTTP/1.1 301 Moved Permanently
Server: nginx/1.0.5
Date: Thu, 24 Nov 2011 23:32:11 GMT
Content-Type: text/html;charset=utf-8
Connection: keep-alive
Content-Length: 127
Location: http://example.com/internal/errorlogs/
答え1
ディレクティブを追加したのはわかりましたがserver_name_in_redirect
、proxy_redirect
ロケーションセッションにディレクティブが必要です
http://wiki.nginx.org/HttpProxyModule#プロキシリダイレクト
あなたはそのようなものを追加します
proxy_redirect http://example.com/ /;