まず、私は既にserverfaultについて同じ質問をしましたが、それほど注目を集めていないようです。これが概念的に間違っている場合は、私に知らせてください。私は喜んでアドバイスされた行動をとるでしょう。nginxのリバースプロキシ環境でruby logout linkを動作させる方法
私はいくつかの内部Webサービスを提供しています。正確なredmineサーバーは、他のサブネットやインターネット上に公開したいものです。私は、アーキテクチャのVirtualBox/dockerの側面は、すべてのリンクとポートの転送が機能するように見えるが、ここではネットワークがどのように見えるのかと直接関係はないと信じている。以下nginxの設定ファイルで
Router/external-dynamic-ip/ddns-hostname:8090 ->
Lan Host/192.168.0.6/10.0.2.2:8090 -> VirtualBox/10.0.2.15
vbox:8090 -> docker-nginx(NAT)/172.17.0.6:80
vbox:8080 -> docker-redmine-tech(NAT)/172.17.0.4:3000
vbox:8081 -> docker-redmine-tech(NAT)/172.17.0.5:3000
、私はhttp://192.168.0.6:8090/tech/
としてLAN上の別のマシン上のWebブラウザを介してドッキングウィンドウ-Redmineのハイテクサービスにアクセスすることができます。ホームページ、画像、スクリプト、ログイン後のすべてのナビゲーションはうまくいくようですが、アドレスバーのベースURLは常にhttp://192.168.0.6:8090/tech/
のままです。そのため、リダイレクトはユーザーには見えません。
http {
include /etc/nginx/mime.types;
log_format upstreamlog '[$time_local] $request_uri $http_referer $http_host $host $server_port $proxy_host $proxy_port $remote_addr - $remote_user - $server_name to: $upstream_addr $http_x_forwarded_for: $status/upstream $upstream_status $request upstream_response_time $upstream_response_time msec $msec request_time $request_time body: $request_body';
access_log /var/log/nginx/access.log upstreamlog;
error_log /var/log/nginx/error.log debug;
rewrite_log on;
underscores_in_headers on;
upstream redmine-tech {
server 10.0.2.15:8080;
}
server {
listen 80 default_server;
location /tech/ {
proxy_set_header Host $http_host/tech;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
add_header Pragma "no-cache";
add_header Cache-Control "no-cache";
proxy_pass http://redmine-tech/;
sub_filter 'action="/' 'action="/tech/';
sub_filter 'href="/' 'href="/tech/';
sub_filter 'src="/' 'src="/tech/';
sub_filter_once off;
}
}
}
redmine Webページは相対URLを使用しているように見えるので、sub_filterが書き換えられます。これはhttp://www.redmine.org/guide
のような絶対的なURLを破りません。
これまでのところとても良いです。私が持っている唯一の問題はlogout
です。ログアウトするとhttp://192.168.0.6
になりますが、代わりにhttp://192.168.0.6:8090/tech/
になると思います。
ログアウトフォームのhtml
コードこれはlogout
を打った後nginxのログである
<form action="/tech/logout" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓" /><input type="hidden" name="authenticity_token" value="cJAHHZxZ0ddFKXSz+vzDze3N4V3yhcxfH/bM0u2IcZJXpsnBBpAr9I4v8U9yLopSpra3WkhB4oOMIqgM7iXE9w==" />
あります。
[08/Nov/2016:13:41:23 +0000] /tech/logout http://192.168.0.6:8090/tech/logout 192.168.0.6:8090 192.168.0.6 80 redmine-tech 80 10.0.2.2 - - - to: 10.0.2.15:8080 -: 302/upstream 302 POST /tech/logout HTTP/1.1 upstream_response_time 0.011 msec 1478612483.524 request_time 0.011 body: _method=post&authenticity_token=Hb1wtuM6oSTWbgTG%2B2Ldr%2BXZZYbv6awGzDIFa7vkv6xqQDvRtuWAnCr4vDrb1SpQP8kl6qVvcuP03LGY%2ByX9rQ%3D%3D
私はRuby on Railsをして/logout
リンクでRedmineのを使用していますルビーによって自動生成されているようです。 find . -name "*.rb" -exec grep -Hn "You are being" {} \;
検索は、次のような結果
./usr/local/bundle/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/redirection.rb:40: body = %(<html><body>You are being <a href="#{ERB::Util.unwrapped_html_escape(uri.to_s)}">redirected</a>.</body></html>)
./usr/local/bundle/gems/actionpack-4.2.7.1/lib/action_controller/metal/redirecting.rb:76: self.response_body = "<html><body>You are being <a href=\"#{ERB::Util.unwrapped_html_escape(location)}\">redirected</a>.</body></html>"
私はrb
ファイルが実際にこのケースで動作することを確認していないが返されますが、それがうまくいかないURI /位置変換であると私は、なぜ非常にわからないように思えます。おそらくPOST
はnginx confに別のhttpヘッダー設定が必要ですが、login/search/registerの新しいアカウントなどのフォームはうまく動作し、 `POST。
私はポートを追加することができないと私はnginxのconfの中proxy_set_header Host $http_host/tech;
で行うよう/tech/
フィールドをホストするようカールの文curl -i http://192.168.0.6:8090/tech/logout -H "Host: 192.168.0.6"
が意味があるかどうかわからないのですが、これは、
HTTP/1.1 302 Found
Server: nginx/1.11.5
Date: Tue, 08 Nov 2016 13:20:10 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Location: http://192.168.0.6/tech/
Cache-Control: no-cache
X-Request-Id: 66707620-ebd2-4c66-af9f-3ba6633d5e7d
X-Runtime: 0.003215
Pragma: no-cache
Cache-Control: no-cache
<html><body>You are being <a href="http://192.168.0.6/tech/">redirected</a>.</body></html>
だから私出力され誰かが光を当ててくれてありがとうと願っています。