I'm attempting to bake the following Nginx reverse proxy configuration into a docker image:

    server {
        listen 80;

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

        location / {

I'm currently just putting that into a volume and mapping it like this:

-v nginx-data:/etc/nginx/conf.d/

That works and it when started the container performs as a reverse proxy, but when I bake it in like this:


  FROM nginx
  COPY gogs.conf /etc/nginx/conf.d/gogs.conf

Start the container from the image like this:

docker run --name gogs-nginx-container -d gogs-nginx

And finally visit it at its assigned IP address I just get the "Welcome to Nginx" page, instead of seeing and it does not redirect to

Any ideas on how to troubleshoot this?

  • 1
    Have you confirm your configuration file is getting stored in the right place? Does the container's log, which should contain log messages from nginx, provide any insight? Oct 6, 2018 at 6:30
  • When running docker logs gogs-nginx-container it only tells me that I tried to connect along with the response codes, which are 304s. I'm copying the configuring to the same place I mount it when running the vanilla nginx image, so it should work ...
    – Ole
    Oct 6, 2018 at 13:44
  • Correct, it should work. Yet based on your description it seems nginx is not using your configuration. Oct 6, 2018 at 14:16

1 Answer 1


Nginx is "Sensitive" to the IP address that it is running on. In my configuration I have the server_name; setting, so the container is started it has to be started on that IP address, otherwise the proxy configuration will not trigger. So this command did the trick:

docker run --name gogs-nginx-proxy --net mk1net --ip -d gogs-nginx

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .