fix(nginx): use hostname variable in proxy_pass to fix DNS + path rewriting
Using $variable:port with no path appended forces DNS re-resolution while nginx still forwards the full original request URI unchanged. Previous attempt ($upstream/api/) was dropping the request path. Co-Authored-By: Paperclip <[email protected]>
This commit is contained in:
1 parent
3436611714
commit
6e6f1a44e4
1 file changed
+4
-3
+4
-3
@@ -2,12 +2,13 @@ server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# Use Docker's embedded DNS so upstream names are re-resolved dynamically
|
||||
# Use Docker's embedded DNS so upstream names are re-resolved dynamically.
|
||||
# Using a variable in proxy_pass forces nginx to use this resolver on each request.
|
||||
resolver 127.0.0.11 valid=5s;
|
||||
|
||||
location /api/ {
|
||||
set $upstream http://api:8000;
|
||||
proxy_pass $upstream/api/;
|
||||
set $api_upstream api;
|
||||
proxy_pass http://$api_upstream:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in new issue
Block a user