nginx icon indicating copy to clipboard operation
nginx copied to clipboard

PROXY PASS in docker-compose doesn't look like it is working.

Open jakelacey2012 opened this issue 6 years ago • 2 comments

First thanks for taking the time in making this :)

I'm a little confused though, for me running this in docker compose doesn't look like proxy pass is working it past the first setting by that I mean its always falling back to the first proxy pass setting.

version: '3'

services:

  nginx:
    image: blacklabelops/nginx
    ports: 
      - "80:80"
      - "443:443"
    volumes:
      - ./private/certs:/opt/nginx/keys:rw
    environment:
      SERVER1REVERSE_PROXY_LOCATION1: /
      SERVER1REVERSE_PROXY_PASS1: http://node-app/1
      SERVER1REVERSE_PROXY_LOCATION2: /alternative
      SERVER1REVERSE_PROXY_PASS2: http://www.alternate.de/
      SERVER1HTTPS_ENABLED: 'true'
      SERVER1CERTIFICATE_FILE: /opt/nginx/keys/_wildcard.app.com+3.pem
      SERVER1CERTIFICATE_KEY: /opt/nginx/keys/_wildcard.app.com+3-key.pem

  node-app:
     ....

This is the logs when running docker-compose up.

nginx_1              | /etc/nginx/conf.d/server1/reverseProxy.conf:
nginx_1              | location ~* ^/(.*) {
nginx_1              |   set $backend "http://node-app/1";
nginx_1              |   set $path $1;
nginx_1              |   if ($path != false) {
nginx_1              |   proxy_pass $backend/$path$is_args$args;
nginx_1              |   }
nginx_1              |   if ($path = false) {
nginx_1              |   proxy_pass $backend$is_args$args;
nginx_1              |   }
nginx_1              |   proxy_set_header X-Forwarded-Proto $scheme;
nginx_1              |   proxy_set_header X-Forwarded-Host $host;
nginx_1              |   proxy_set_header X-Forwarded-Server $host;
nginx_1              |   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
nginx_1              |   proxy_set_header X-Real-IP $remote_addr;
nginx_1              |   proxy_set_header Host $host;
nginx_1              |   port_in_redirect off;
nginx_1              | }
nginx_1              | location ~* ^/alternative(.*) {
nginx_1              |   set $backend "http://www.alternate.de/";
nginx_1              |   set $path $1;
nginx_1              |   if ($path != false) {
nginx_1              |   proxy_pass $backend/$path$is_args$args;
nginx_1              |   }
nginx_1              |   if ($path = false) {
nginx_1              |   proxy_pass $backend$is_args$args;
nginx_1              |   }
nginx_1              |   proxy_set_header X-Forwarded-Proto $scheme;
nginx_1              |   proxy_set_header X-Forwarded-Host $host;
nginx_1              |   proxy_set_header X-Forwarded-Server $host;
nginx_1              |   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
nginx_1              |   proxy_set_header X-Real-IP $remote_addr;
nginx_1              |   proxy_set_header Host $host;
nginx_1              |   port_in_redirect off;
nginx_1              | }
nginx_1              | /etc/nginx/conf.d/server1.conf:
nginx_1              | server {
nginx_1              |   listen              80 default_server;
nginx_1              |   listen             443 ssl;
nginx_1              |   keepalive_timeout  0;
nginx_1              |   server_name        _;
nginx_1              |
nginx_1              |   ssl_certificate         /opt/nginx/keys/_wildcard.app.com+3.pem;
nginx_1              |   ssl_certificate_key     /opt/nginx/keys/_wildcard.app.com+3-key.pem;
nginx_1              |   # Load configuration files for the default server block.
nginx_1              |   include /etc/nginx/conf.d/server1/*.conf;
nginx_1              | }
nginx_1              | worker_processes auto;
nginx_1              | error_log /dev/stdout info;
nginx_1              |
nginx_1              | events {
nginx_1              |   worker_connections 1024;
nginx_1              | }
nginx_1              |
nginx_1              | http {
nginx_1              |   log_format  main  '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
nginx_1              |   access_log /dev/stdout main;
nginx_1              |
nginx_1              |   sendfile              on;
nginx_1              |   tcp_nopush            on;
nginx_1              |   tcp_nodelay           on;
nginx_1              |
nginx_1              |   resolver 127.0.0.11  ipv6=off valid=30s;
nginx_1              |
nginx_1              |   include mime.types;
nginx_1              |   client_max_body_size  100m;
nginx_1              |   keepalive_timeout     65;
nginx_1              |   types_hash_max_size   2048;
nginx_1              |
nginx_1              |   # Load modular configuration files from the /etc/nginx/conf.d directory.
nginx_1              |   # See http://nginx.org/en/docs/ngx_core_module.html#include
nginx_1              |   # for more information.
nginx_1              |   include /etc/nginx/conf.d/*.conf;
nginx_1              | }
nginx_1              | 2018/08/26 08:34:28 [notice] 5#5: using the "epoll" event method
nginx_1              | 2018/08/26 08:34:28 [notice] 5#5: nginx/1.14.0
nginx_1              | 2018/08/26 08:34:28 [notice] 5#5: OS: Linux 4.9.87-linuxkit-aufs
nginx_1              | 2018/08/26 08:34:28 [notice] 5#5: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx_1              | 2018/08/26 08:34:28 [notice] 5#5: start worker processes
nginx_1              | 2018/08/26 08:34:28 [notice] 5#5: start worker process 41
nginx_1              | 2018/08/26 08:34:28 [notice] 5#5: start worker process 42

Do you know if its something wrong I'm doing or ?....

jakelacey2012 avatar Aug 26 '18 08:08 jakelacey2012

So it looks like this could be referring to #39 as the regex for the paths seem to be messing things up, going to use this tag 1.10.1-r1 in the interim whilst the documentation is updated.

jakelacey2012 avatar Aug 26 '18 09:08 jakelacey2012

However using that version I cannot use

      SERVER1REVERSE_PROXY_APPLICATION2: custom
      SERVER1REVERSE_PROXY_DIRECTIVE2FIELD1: 'try_files $$uri /var/lib/nginx/html/f/index.html'

Any advice?

jakelacey2012 avatar Aug 26 '18 17:08 jakelacey2012