Nginx – forwarding docker container to nginx port

centoscentos7dockernginx

i have a server that has nginx run on it, and a domain that is been pointed to server, and i have CWP that configured to has nginx on the server.

now i have a docker container that runs on port 3000 of the same server and if i curl into it like curl http://localhost:3000, i would get the result.

my question is that how can i forward my domain requests to my docker container that is running on the server, i already did some search, but in my case please not that i dont have any container on the server that boots up nginx separately , its the default nginx on server,

now the question is how can i map port 80 of server (that already pointed to my domain.com) to my running docker container???

Best Answer

Create a server block on the NGINX in the host

server {
    listen       80;
    server_name  domain.tld;

    location / {
        proxy_pass http://localhost:3000;
    } 
}