server {
listen 80;
server_name mydomain.com www.mydomain.com;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
***.**.***.** - - [13/Dec/2021:17:29:00 +0300] "GET /api/users HTTP/1.1" 404 134 "-" "PostmanRuntime/7.28.4
, d логах ошибок ничего нет.error_log /path/to/log debug;
2021/12/13 23:00:17 [debug] 4148592#4148592: epoll add event: fd:8 op:1 ev:10000001
2021/12/13 23:00:17 [debug] 4148593#4148593: epoll add event: fd:8 op:1 ev:10000001
2021/12/13 23:00:17 [debug] 4148594#4148594: epoll add event: fd:8 op:1 ev:10000001
2021/12/13 23:00:25 [debug] 4148542#4148542: accept on 0.0.0.0:80, ready: 1
2021/12/13 23:00:25 [debug] 4148542#4148542: posix_memalign: 00005574D87FAE90:512 @16
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 accept: ***.**.**.**:47498 fd:58 // тут мой ip
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 event timer add: 58: 60000:12037415010
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 reusable connection: 1
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 epoll add event: fd:58 op:1 ev:80002001
2021/12/13 23:00:25 [debug] 4148542#4148542: accept() not ready (11: Resource temporarily unavailable)
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 http wait request handler
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 malloc: 00005574D873B600:1024
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 recv: eof:0, avail:-1
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 recv: fd:58 169 of 1024
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 reusable connection: 0
2021/12/13 23:00:25 [debug] 4148542#4148542: *1 posix_memalign: 00005574D8784B50:4096 @16
proxy_pass http://localhost:8080;
Если директива proxy_pass указана с URI, то при передаче запроса серверу часть нормализованного URI запроса, соответствующая location, заменяется на URI, указанный в директиве:
location /api {
proxy_pass http://localhost:8080/api;
curl -iL http://localhost:8080/api
curl -H 'Host: mydomain.com' http://localhost:8080/api/users
proxy_set_header Host localhost;
proxy_set_header Host localhost;
. Но лучше конечно настроить...proxy_set_header Host localhost;
или proxy_set_header Host mydomain.com;