Удалить подпуть (контекстный корень) в nginx для java приложения

Приложение находится на сервере Payara и имеет контекстный корень nocodeapp-web-front-1.0

Я не хочу иметь этот контекстный корень в url. Этот конфиг nginx дает желаемый результат для страницы index приложения (она находится по адресу https://test.nocodefunctions.com):

upstream payara {
    least_conn;

    server localhost:8080 max_fails=3 fail_timeout=5s;
    server localhost:8181 max_fails=3 fail_timeout=5s;
}
server {
    if ($host = test.nocodefunctions.com) {
        return 301 https://$host$request_uri;
    }


    listen        80;
    access_log /var/log/nginx/payara-access.log;
    error_log /var/log/nginx/payara-error.log;
    
    client_max_body_size 100M;
    server_name   test.nocodefunctions.com;
    return        301 https://$host$request_uri;


}

server {
    listen        443 ssl;
    server_name   test.nocodefunctions.com;
    client_max_body_size 100M;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";

    location /nocodeapp-web-front-1.0 {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Proto https;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_no_cache $cookie_nocache  $arg_nocache$arg_comment;
            proxy_no_cache $http_pragma     $http_authorization;
            proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment;
            proxy_cache_bypass $http_pragma $http_authorization;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host:$server_port;
            add_header Access-Control-Allow-Origin *;
            proxy_set_header Access-Control-Allow-Origin *;
            proxy_pass http://payara$request_uri;
    }
    
    location = / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Proto https;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://payara/nocodeapp-web-front-1.0$request_uri$is_args$args;
    }

    ssl_certificate /etc/letsencrypt/live/xxxxxx/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/xxxxxx/privkey.pem; # managed by Certbot
}

Однако когда мы переходим в приложении, нажимая на кнопку "Go", страница по адресу /choosefunction.html отображается так:

https://test.nocodefunctions.com/nocodeapp-web-front-1.0/choosefunction.html

... подпункт nocodeapp-web-front-1.0 снова появился?

Как я могу получить:

https://test.nocodefunctions.com/choosefunction.html

NB: Я проверил эти два вопроса 1 & 2, они не работают для меня

-1
задан 16 May 2021 в 14:00
1 ответ

Вам необходимо указать корневой URL-адрес приложения в конфигурации приложения. Это заставит приложение генерировать правильные URL-адреса для ссылок и ресурсов.

1
ответ дан 28 July 2021 в 15:22

Теги

Похожие вопросы