AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1063715
Accepted
seinecle
seinecle
Asked: 2021-05-17 03:00:09 +0800 CST2021-05-17 03:00:09 +0800 CST 2021-05-17 03:00:09 +0800 CST

在 nginx 中删除 Java 应用程序的子路径(上下文根)

  • 772

该应用程序位于 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
}

但是,当我们通过单击“开始”按钮在应用程序中导航时,页面/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和2,它们对我不起作用

java glassfish nginx proxypass
  • 1 1 个回答
  • 214 Views

1 个回答

  • Voted
  1. Best Answer
    Tero Kilkanen
    2021-05-17T04:14:09+08:002021-05-17T04:14:09+08:00

    您需要在应用程序配置中指定应用程序的根 URL。这将使应用程序为链接和资源生成正确的 URL。

    • 1

相关问题

  • jvm性能调优技巧/资源?

  • Linux 服务器上的多个*几乎*相同的进程

  • 您认为 Linux 服务器上的 Java 是个问题吗?[关闭]

  • 如何定期复制 SVN 存储库而不会丢失目标标签和分支?

  • GlassFish 更改 Web 服务的端口

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve