该应用程序位于 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
答案1
您需要在应用程序配置中指定应用程序的根 URL。这将使应用程序为链接和资源生成正确的 URL。