I have an app in a docker container running at the port number 3000, exposed to the host (port 3050 mapped to the container's port 3000), and I would like to use this nginx-proxy to point urls like http://localhost/users to point/proxy to http://localhost:3050/users.
I have this block in my docker-compose.yml file:
nginx_service:
image: jwilder/nginx-proxy
container_name: nginx_server
ports:
- "80:80"
- "443:443"
volumes:
- ./ssl_certs:/etc/nginx/certs
- /var/run/docker.sock:/tmp/docker.sock:ro
Below is the container defined in docker-compose.yml that runs my app on the port 3000 in the docker container:
api:
build: .
container_name: api
environment:
- VIRTUAL_HOST= service.myserver.com
- VIRTUAL_PROTO=https
volumes:
- "./API:/host"
links:
- Mongo:Mongo
ports:
- "3050:3000"
After I start up the docker containers, I can open http://localhost:3050/users in browser, but not http://localhost/users, which gives me a 503 error for Service Temporarily Unavailable.
Maybe I am getting the whole idea wrong, could someone help or correct me with nginx reverse proxy?