###前提・実現したいこと
AWSの1つのインスタンス内に, RailsアプリとRedashの2つのアプリがあり、それぞれを
hoge.com/ -> Railsアプリ hoge.com/redash -> Redashアプリ
とプロキシしてほしいのですが、Redashへプロキシされた際にjs, css, images, fontsが読み込まれません。
/js/hoge.js
を取りに行っており、該当ファイルがなくてエラーが出てしまいます。
これを/redash/js/hoge.js
へ取りに行ってほしいのです。
###現状のnginx.conf
Railsアプリとnginx.confはUnixドメインソケットで接続されいます。
またdocker-composeでRailsとRedashは動いているため, upstreamに書いてあるredash-server:5000
でredashへ飛べます。
upstream puma { server unix:/opt/app/tmp/sockets/puma.sock; } upstream redash_servers { server redash-server:5000; } server { listen 80; root /opt/app/public; client_max_body_size 50M; error_page 404 422 500; if ($http_x_forwarded_port = 80) { return 301 https://$host$request_uri; } location ^~ /redash/ { proxy_pass http://redash_servers/; } location ~ .*.(jpg|JPG|gif|GIF|png|PNG|swf|SWF|css|CSS|js|JS|inc|INC|ico|ICO|js.html|otf) { access_log off; index index.html; ssi on; expires 180s; break; } location / { try_files $uri $uri/index.html $uri.html @puma; } location @puma { if ($request_uri = /health_check) { access_log off; } proxy_redirect off; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; proxy_set_header X-Forwarded-Port $http_x_forwarded_port; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $http_x_forwarded_for; proxy_set_header X-Forwarded-For $http_x_forwarded_for; proxy_pass http://puma; } }
###試したこと
proxy_set_header Host $http_host;
の記述
→/redash
でログイン画面へリダイレクトされるが、その際に/redash/login
ではなく/login
へリダイレクトされてしまいRailsの404が表示される
お分かりになる方がおられましたら、お教え頂ければ嬉しく思います。
あなたの回答
tips
プレビュー