containerized reverse proxy showing default site










0














No matter what I do, I keep running into the problem where my website publishes the default nginx website. I'm trying to dockerize my webserver such that it can point to home assistant running in another container. I've been able to get it to work when both were hosted on the same raspi, not running in containers, but not when both are running in containers.



I've attached my nginx.conf, Dockerfile and default.conf that I was using to start the environment up. I've spent the last 2 days looking for someone who was trying to do something similar, but I assume I'm making such a stupid mistake that most have been able to figure it out on their own..



nginx.conf:



user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events
worker_connections 1024;



http
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

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



default.conf (/etc/nginx/conf.d/hass.conf)



 map $http_upgrade $connection_upgrade 
default upgrade;
'' close;


server
# Update this line to be your domain
server_name nekohouse.ca;

# These shouldn't need to be changed
listen [::]:80 default_server ipv6only=off;
return 301 https://$host$request_uri;


server
# Update this line to be your domain
server_name nekohouse.ca;

# Ensure these lines point to your SSL certificate and key
ssl_certificate fullchain.pem;
ssl_certificate_key privkey.pem;
# Use these lines instead if you created a self-signed certificate
# ssl_certificate /etc/nginx/ssl/cert.pem;
# ssl_certificate_key /etc/nginx/ssl/key.pem;

# Ensure this line points to your dhparams file
ssl_dhparam /etc/nginx/dhparams.pem;


# These shouldn't need to be changed
listen [::]:443 default_server ipv6only=off; # if your nginx version is >= 1.9.5 you can also add the "http2" flag here
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

proxy_buffering off;

location /
proxy_pass http://localhost:8123;
proxy_set_header Host $host;
proxy_redirect http:// https://;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;




default.conf (/etc/nginx/conf.d/default.conf)



server 
listen 8100;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location /
root /usr/share/nginx/html;
index index.html index.htm;


#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html
root /usr/share/nginx/html;


# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$
# proxy_pass http://127.0.0.1;
#

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ .php$
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht
# deny all;
#










share|improve this question


























    0














    No matter what I do, I keep running into the problem where my website publishes the default nginx website. I'm trying to dockerize my webserver such that it can point to home assistant running in another container. I've been able to get it to work when both were hosted on the same raspi, not running in containers, but not when both are running in containers.



    I've attached my nginx.conf, Dockerfile and default.conf that I was using to start the environment up. I've spent the last 2 days looking for someone who was trying to do something similar, but I assume I'm making such a stupid mistake that most have been able to figure it out on their own..



    nginx.conf:



    user nginx;
    worker_processes 1;

    error_log /var/log/nginx/error.log warn;
    pid /var/run/nginx.pid;


    events
    worker_connections 1024;



    http
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    #tcp_nopush on;

    keepalive_timeout 65;

    #gzip on;

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



    default.conf (/etc/nginx/conf.d/hass.conf)



     map $http_upgrade $connection_upgrade 
    default upgrade;
    '' close;


    server
    # Update this line to be your domain
    server_name nekohouse.ca;

    # These shouldn't need to be changed
    listen [::]:80 default_server ipv6only=off;
    return 301 https://$host$request_uri;


    server
    # Update this line to be your domain
    server_name nekohouse.ca;

    # Ensure these lines point to your SSL certificate and key
    ssl_certificate fullchain.pem;
    ssl_certificate_key privkey.pem;
    # Use these lines instead if you created a self-signed certificate
    # ssl_certificate /etc/nginx/ssl/cert.pem;
    # ssl_certificate_key /etc/nginx/ssl/key.pem;

    # Ensure this line points to your dhparams file
    ssl_dhparam /etc/nginx/dhparams.pem;


    # These shouldn't need to be changed
    listen [::]:443 default_server ipv6only=off; # if your nginx version is >= 1.9.5 you can also add the "http2" flag here
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
    ssl on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;

    proxy_buffering off;

    location /
    proxy_pass http://localhost:8123;
    proxy_set_header Host $host;
    proxy_redirect http:// https://;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;




    default.conf (/etc/nginx/conf.d/default.conf)



    server 
    listen 8100;
    server_name localhost;

    #charset koi8-r;
    #access_log /var/log/nginx/host.access.log main;

    location /
    root /usr/share/nginx/html;
    index index.html index.htm;


    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html
    root /usr/share/nginx/html;


    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ .php$
    # proxy_pass http://127.0.0.1;
    #

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ .php$
    # root html;
    # fastcgi_pass 127.0.0.1:9000;
    # fastcgi_index index.php;
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    # include fastcgi_params;
    #

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /.ht
    # deny all;
    #










    share|improve this question
























      0












      0








      0







      No matter what I do, I keep running into the problem where my website publishes the default nginx website. I'm trying to dockerize my webserver such that it can point to home assistant running in another container. I've been able to get it to work when both were hosted on the same raspi, not running in containers, but not when both are running in containers.



      I've attached my nginx.conf, Dockerfile and default.conf that I was using to start the environment up. I've spent the last 2 days looking for someone who was trying to do something similar, but I assume I'm making such a stupid mistake that most have been able to figure it out on their own..



      nginx.conf:



      user nginx;
      worker_processes 1;

      error_log /var/log/nginx/error.log warn;
      pid /var/run/nginx.pid;


      events
      worker_connections 1024;



      http
      include /etc/nginx/mime.types;
      default_type application/octet-stream;

      log_format main '$remote_addr - $remote_user [$time_local] "$request" '
      '$status $body_bytes_sent "$http_referer" '
      '"$http_user_agent" "$http_x_forwarded_for"';

      access_log /var/log/nginx/access.log main;

      sendfile on;
      #tcp_nopush on;

      keepalive_timeout 65;

      #gzip on;

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



      default.conf (/etc/nginx/conf.d/hass.conf)



       map $http_upgrade $connection_upgrade 
      default upgrade;
      '' close;


      server
      # Update this line to be your domain
      server_name nekohouse.ca;

      # These shouldn't need to be changed
      listen [::]:80 default_server ipv6only=off;
      return 301 https://$host$request_uri;


      server
      # Update this line to be your domain
      server_name nekohouse.ca;

      # Ensure these lines point to your SSL certificate and key
      ssl_certificate fullchain.pem;
      ssl_certificate_key privkey.pem;
      # Use these lines instead if you created a self-signed certificate
      # ssl_certificate /etc/nginx/ssl/cert.pem;
      # ssl_certificate_key /etc/nginx/ssl/key.pem;

      # Ensure this line points to your dhparams file
      ssl_dhparam /etc/nginx/dhparams.pem;


      # These shouldn't need to be changed
      listen [::]:443 default_server ipv6only=off; # if your nginx version is >= 1.9.5 you can also add the "http2" flag here
      add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
      ssl on;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
      ssl_prefer_server_ciphers on;
      ssl_session_cache shared:SSL:10m;

      proxy_buffering off;

      location /
      proxy_pass http://localhost:8123;
      proxy_set_header Host $host;
      proxy_redirect http:// https://;
      proxy_http_version 1.1;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;




      default.conf (/etc/nginx/conf.d/default.conf)



      server 
      listen 8100;
      server_name localhost;

      #charset koi8-r;
      #access_log /var/log/nginx/host.access.log main;

      location /
      root /usr/share/nginx/html;
      index index.html index.htm;


      #error_page 404 /404.html;

      # redirect server error pages to the static page /50x.html
      #
      error_page 500 502 503 504 /50x.html;
      location = /50x.html
      root /usr/share/nginx/html;


      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ .php$
      # proxy_pass http://127.0.0.1;
      #

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      #location ~ .php$
      # root html;
      # fastcgi_pass 127.0.0.1:9000;
      # fastcgi_index index.php;
      # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
      # include fastcgi_params;
      #

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /.ht
      # deny all;
      #










      share|improve this question













      No matter what I do, I keep running into the problem where my website publishes the default nginx website. I'm trying to dockerize my webserver such that it can point to home assistant running in another container. I've been able to get it to work when both were hosted on the same raspi, not running in containers, but not when both are running in containers.



      I've attached my nginx.conf, Dockerfile and default.conf that I was using to start the environment up. I've spent the last 2 days looking for someone who was trying to do something similar, but I assume I'm making such a stupid mistake that most have been able to figure it out on their own..



      nginx.conf:



      user nginx;
      worker_processes 1;

      error_log /var/log/nginx/error.log warn;
      pid /var/run/nginx.pid;


      events
      worker_connections 1024;



      http
      include /etc/nginx/mime.types;
      default_type application/octet-stream;

      log_format main '$remote_addr - $remote_user [$time_local] "$request" '
      '$status $body_bytes_sent "$http_referer" '
      '"$http_user_agent" "$http_x_forwarded_for"';

      access_log /var/log/nginx/access.log main;

      sendfile on;
      #tcp_nopush on;

      keepalive_timeout 65;

      #gzip on;

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



      default.conf (/etc/nginx/conf.d/hass.conf)



       map $http_upgrade $connection_upgrade 
      default upgrade;
      '' close;


      server
      # Update this line to be your domain
      server_name nekohouse.ca;

      # These shouldn't need to be changed
      listen [::]:80 default_server ipv6only=off;
      return 301 https://$host$request_uri;


      server
      # Update this line to be your domain
      server_name nekohouse.ca;

      # Ensure these lines point to your SSL certificate and key
      ssl_certificate fullchain.pem;
      ssl_certificate_key privkey.pem;
      # Use these lines instead if you created a self-signed certificate
      # ssl_certificate /etc/nginx/ssl/cert.pem;
      # ssl_certificate_key /etc/nginx/ssl/key.pem;

      # Ensure this line points to your dhparams file
      ssl_dhparam /etc/nginx/dhparams.pem;


      # These shouldn't need to be changed
      listen [::]:443 default_server ipv6only=off; # if your nginx version is >= 1.9.5 you can also add the "http2" flag here
      add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
      ssl on;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
      ssl_prefer_server_ciphers on;
      ssl_session_cache shared:SSL:10m;

      proxy_buffering off;

      location /
      proxy_pass http://localhost:8123;
      proxy_set_header Host $host;
      proxy_redirect http:// https://;
      proxy_http_version 1.1;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;




      default.conf (/etc/nginx/conf.d/default.conf)



      server 
      listen 8100;
      server_name localhost;

      #charset koi8-r;
      #access_log /var/log/nginx/host.access.log main;

      location /
      root /usr/share/nginx/html;
      index index.html index.htm;


      #error_page 404 /404.html;

      # redirect server error pages to the static page /50x.html
      #
      error_page 500 502 503 504 /50x.html;
      location = /50x.html
      root /usr/share/nginx/html;


      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ .php$
      # proxy_pass http://127.0.0.1;
      #

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      #location ~ .php$
      # root html;
      # fastcgi_pass 127.0.0.1:9000;
      # fastcgi_index index.php;
      # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
      # include fastcgi_params;
      #

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /.ht
      # deny all;
      #







      docker nginx






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 1:12









      Baron

      32




      32






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The problem is because of this line



          proxy_pass http://localhost:8123;


          When running in containers, you should understand that localhost refers to the nginx container and not the docker host.



          So, you should either change localhost to the hostname of your docker host or use docker-compose so that you can change it to the name of the container defined.



          If you are just running the containers separately, you could also just use the container IP for now but note that it will change everytime the container is restarted.






          share|improve this answer




















          • Thanks for the tip. I thought this might be the problem, so I built a docker-compose.yml file. Shortened version: version: '3' services: homeassistant: networks: - hass nginx: networks: - hass networks: hass: I also changed that localhost line to: http://<stackname>_homeassistant:8123; It runs.. but it's still not forwarding to my other container...
            – Baron
            Nov 13 at 2:36










          • It has to be just http://homeassistant:8123
            – Pramodh Valavala
            Nov 13 at 17:03










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244977%2fcontainerized-reverse-proxy-showing-default-site%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The problem is because of this line



          proxy_pass http://localhost:8123;


          When running in containers, you should understand that localhost refers to the nginx container and not the docker host.



          So, you should either change localhost to the hostname of your docker host or use docker-compose so that you can change it to the name of the container defined.



          If you are just running the containers separately, you could also just use the container IP for now but note that it will change everytime the container is restarted.






          share|improve this answer




















          • Thanks for the tip. I thought this might be the problem, so I built a docker-compose.yml file. Shortened version: version: '3' services: homeassistant: networks: - hass nginx: networks: - hass networks: hass: I also changed that localhost line to: http://<stackname>_homeassistant:8123; It runs.. but it's still not forwarding to my other container...
            – Baron
            Nov 13 at 2:36










          • It has to be just http://homeassistant:8123
            – Pramodh Valavala
            Nov 13 at 17:03















          0














          The problem is because of this line



          proxy_pass http://localhost:8123;


          When running in containers, you should understand that localhost refers to the nginx container and not the docker host.



          So, you should either change localhost to the hostname of your docker host or use docker-compose so that you can change it to the name of the container defined.



          If you are just running the containers separately, you could also just use the container IP for now but note that it will change everytime the container is restarted.






          share|improve this answer




















          • Thanks for the tip. I thought this might be the problem, so I built a docker-compose.yml file. Shortened version: version: '3' services: homeassistant: networks: - hass nginx: networks: - hass networks: hass: I also changed that localhost line to: http://<stackname>_homeassistant:8123; It runs.. but it's still not forwarding to my other container...
            – Baron
            Nov 13 at 2:36










          • It has to be just http://homeassistant:8123
            – Pramodh Valavala
            Nov 13 at 17:03













          0












          0








          0






          The problem is because of this line



          proxy_pass http://localhost:8123;


          When running in containers, you should understand that localhost refers to the nginx container and not the docker host.



          So, you should either change localhost to the hostname of your docker host or use docker-compose so that you can change it to the name of the container defined.



          If you are just running the containers separately, you could also just use the container IP for now but note that it will change everytime the container is restarted.






          share|improve this answer












          The problem is because of this line



          proxy_pass http://localhost:8123;


          When running in containers, you should understand that localhost refers to the nginx container and not the docker host.



          So, you should either change localhost to the hostname of your docker host or use docker-compose so that you can change it to the name of the container defined.



          If you are just running the containers separately, you could also just use the container IP for now but note that it will change everytime the container is restarted.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 5:49









          Pramodh Valavala

          47127




          47127











          • Thanks for the tip. I thought this might be the problem, so I built a docker-compose.yml file. Shortened version: version: '3' services: homeassistant: networks: - hass nginx: networks: - hass networks: hass: I also changed that localhost line to: http://<stackname>_homeassistant:8123; It runs.. but it's still not forwarding to my other container...
            – Baron
            Nov 13 at 2:36










          • It has to be just http://homeassistant:8123
            – Pramodh Valavala
            Nov 13 at 17:03
















          • Thanks for the tip. I thought this might be the problem, so I built a docker-compose.yml file. Shortened version: version: '3' services: homeassistant: networks: - hass nginx: networks: - hass networks: hass: I also changed that localhost line to: http://<stackname>_homeassistant:8123; It runs.. but it's still not forwarding to my other container...
            – Baron
            Nov 13 at 2:36










          • It has to be just http://homeassistant:8123
            – Pramodh Valavala
            Nov 13 at 17:03















          Thanks for the tip. I thought this might be the problem, so I built a docker-compose.yml file. Shortened version: version: '3' services: homeassistant: networks: - hass nginx: networks: - hass networks: hass: I also changed that localhost line to: http://<stackname>_homeassistant:8123; It runs.. but it's still not forwarding to my other container...
          – Baron
          Nov 13 at 2:36




          Thanks for the tip. I thought this might be the problem, so I built a docker-compose.yml file. Shortened version: version: '3' services: homeassistant: networks: - hass nginx: networks: - hass networks: hass: I also changed that localhost line to: http://<stackname>_homeassistant:8123; It runs.. but it's still not forwarding to my other container...
          – Baron
          Nov 13 at 2:36












          It has to be just http://homeassistant:8123
          – Pramodh Valavala
          Nov 13 at 17:03




          It has to be just http://homeassistant:8123
          – Pramodh Valavala
          Nov 13 at 17:03

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244977%2fcontainerized-reverse-proxy-showing-default-site%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          Evgeni Malkin