I'm trying to run nginx as a reverse proxy for Gogs using Docker. First I setup gogs and I can see a web page for it rendered on:

But I want to have NGINX proxy it for me such that I can leave the port (3000) off the URL. The instructions I'm following come from the NGINX section of this tutorial:


In order to get this working with docker I created a nginx-data volume, and placed the nginx configuration file in that volume naming it gogs. My configuration file looks like this:

server {
    listen 80;

    proxy_set_header X-Real-IP  $remote_addr; # pass on real client IP

    location / {

And it's located at the root of the nginx-data volume. I start the nginx container like this:

docker run --name docker-nginx -p 80:80 --net mk1net --ip -v nginx-data:/etc/nginx/sites-enabled/ -d nginx

Now when I visit I'm expecting to see the Gogs page, but I'm just getting the "Welcome to NGINX" page.






Place the proxy configuration in a file named gogs.conf within the docker volume and map it like this:

docker run --name docker-nginx -p 80:80 --net mk1net --ip -v nginx-data:/etc/nginx/conf.d/ -d nginx


To see how nginx is configured on a default Ubuntu install I installed it sudo apt-get install nginx and took a look at the configuration file /etc/nginx/nginx.conf. It includes these two lines at the bottom of the configuration:

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

So I compared that to the nginx configuration of the docker container:

docker run --rm -it nginx /bin/ash
root@9475f1693539: cat /etc/nginx/nginx.conf

This configuration only has this line:

include /etc/nginx/conf.d/*.conf;

Hence the configuration from /etc/nginx/sites-enabled/ is not included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.