P
P
plavsk2020-11-17 19:46:29
Nginx
plavsk, 2020-11-17 19:46:29

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

Help setting up nginx
There are several containerized application applications hanging in docker on the same machine but on different ports.
Each application separately works on different ports

I want the following scheme of operation
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 it works partially, styles work, it looks for them, looks for them in app1, entry into app2 subdirectories does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Vasilyev, 2020-11-17
@vasilyevmn

I realize the answer is off-topic, but it was for similar reasons that I dropped nginx as a reverse.
Tired of setting up.
I advise traefik, spend a day studying and forget these configs like a bad dream:
https://habr.com/ru/post/508636/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question