I try to connect my service run on windows wsl2 with docker nginx as proxy, but the request always timeout. Here my configuration & docker compose file.
Docker-compose:
version: '3'
services:
proxy:
image: nginx:alpine
ports:
- "8999:80"
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- "./api.conf:/etc/nginx/nginx.conf"
api.conf
events {
worker_connections 1024;
}
http {
server{
listen 80;
location /v1/api1/ {
rewrite ^/v1/api1/(.*)$ /v1/$1 break;
proxy_pass http://host.docker.internal:3000/;
}
location /v1/api2/ {
rewrite ^/v1/api2/(.*)$ /v1/$1 break;
proxy_pass http://host.docker.internal:4000/;
}
}
Error message
[error] 33#33: *2 upstream timed out (110: Operation timed out) while connecting to upstream, client: 172.19.0.1, server: , request: "POST /v1/account/buyer/auth/login HTTP/1.1", upstream: "http://192.168.65.1:3000/v1/data", host: "localhost:8999"
The service is fine when I access in normal way, using localhost, for example
http://localhost:3000/v1/data
I try to using proxy and make api call into only 1 endpoint.