I have a nginx webserver configured as follows:
server {
listen 3000;
listen [::]:3000;
server_name .+;
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log debug;
gzip on;
gzip_static on;
gzip_comp_level 9;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/jpg image/png image/jpeg image/svg;
gzip_min_length 256;
gzip_vary on;
index index.html;
root /usr/share/nginx/html;
set $api https://some_ip:some_port;
location ~ ^/api(/.*)$ {
rewrite ^/api(/.*)?$ $1 break;
proxy_pass $api$request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $server_name;
}
location / {
try_files $uri $uri/ /index.html;
}
client_max_body_size 1M;
keepalive_timeout 10;
}
From my application, I make a request to the api as follows:
const res = await fetch(`api/sub`, {
method: 'POST',
headers: {
...headers
},
body: ...body,
});
If I make the request on my dev server with a proxy, it gets resolved to
https://some_ip:some_port/sub
and everything is fine.
If I make the request on my production nginx server, I get a Error 502: Bad Gateway
.
In the error logs, it says: no resolver defined to resolve some_ip
.
My suspicion is, that the proxy does not resolve my request as I intend. Is there any way to see the address, my request is resolved to?
I already tried to add $upstream_addr
to the logging in the config, but it tells me invalid parameter
.