One domain and multiple applications in docker how to reverse nginx proxy?

  • 0
    Help configure nginx
    There are several containerized applications running in docker on the same machine but on different ports.
    Each application individually runs on different ports.

    I want the following scheme of work
    domain.ru / app1
    domain.ru/v1 - / app2
    domain.ru/v3 - / app3

    Config

    location / {
            if ($request_method !~ ^(OPTIONS|GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT|PROPFIND|PROPPATCH|MKCOL|COPY|MOVE|LOCK|UNLOCK|VERSION-CONTROL|REPORT|CHECKOUT|CHECKIN|UNCHECKOUT|MKWORKSPACE|UPDATE|LABEL|MERGE|BASELINE-CONTROL|MKACTIVITY|ORDERPATCH|ACL|SEARCH|MKCALENDAR|PATCH)$) {
                return 405;
            }
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            client_max_body_size 1024m;
            proxy_connect_timeout 1s;
            proxy_redirect off;
            {#- it's allways eth0 interface in VM #}
            proxy_pass http://127.0.0.1:3000;
        }
        
        location /education {
            if ($request_method !~ ^(OPTIONS|GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT|PROPFIND|PROPPATCH|MKCOL|COPY|MOVE|LOCK|UNLOCK|VERSION-CONTROL|REPORT|CHECKOUT|CHECKIN|UNCHECKOUT|MKWORKSPACE|UPDATE|LABEL|MERGE|BASELINE-CONTROL|MKACTIVITY|ORDERPATCH|ACL|SEARCH|MKCALENDAR|PATCH)$) {
                return 405;
            }
            proxy_set_header Host $host;
            proxy_set_header X-Scheme https;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            # WS settings
            proxy_http_version 1.1;
            proxy_read_timeout 900s;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            {#- it's allways eth0 interface in VM #}
            proxy_pass http://127.0.0.1:9000;
        }


    But this works partially, re works styles it looks for them looks in app1 does not work entry into subdirectories app2
    Nginx Anonymous, Nov 19, 2019

  • 1 Answers
  • 0
    I understand that the answer is off-topic, but it is for similar reasons that I abandoned nginx as a reverse.

    Tired of adjusting.



    I advise traefik, spend a day studying and forget these configs like a bad dream:

    https://habr.com/en/post/508636/
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!