I have the following task:
I need to use Google Chrome browser to navigate to:
https://mytestserver.com/users/list
and this should be redirected to my local Java server that listens to Http requests on port 8080.
I'm running on Mac OSX, to achieve that I did the following:
- Added
127.0.0.1 mytestserver.com
to /etc/host file. - Installed Nginx server on Docker container with the following config:
events {
worker_connections 1024;
}
http {
server {
listen 443 ssl;
server_name mytestserver.com;
ssl_certificate /etc/nginx/certs/star_com.crt;
ssl_certificate_key /etc/nginx/certs/star_com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
proxy_set_header X-Forwarded-Proto $scheme;
location / {
proxy_pass http://127.0.0.1:8080/;
}
}
}
Then I run my local application server and listen to incoming Http requests on 8080,
and finally I try to run https://mytestserver.com/users/list
and I'm getting 502 error.
In the Nginx logs I can see this error:
2021/07/06 20:37:47 [error] 23#23: *3 connect() failed (111: Connection refused)
while connecting to upstream, client: 172.17.0.1, server: mytestserver.com, request:
"GET /users/list HTTP/1.1", upstream: "http://127.0.0.1:8080/users/list", host: "mytestserver.com"
What am I missing here?