【问题标题】:Confgure nginx as reverse proxy for wildfly web applications将 nginx 配置为 Wildfly Web 应用程序的反向代理
【发布时间】:2017-04-12 10:07:41
【问题描述】:

我在 Wildfly 10.1 应用服务器上部署了一个 webapp。 此 webapp 被监听:http://localhost:8080/app-profile-jsp/ (1)

我成功安装了nginx。服务器已成功安装,我测试提供静态网页和图像。

现在我想配置 nginx 以从 “http://www.frizio.local” (2) 网址。 我在 /etc/hosts 中配置了这个地址。

我在nginx中的配置如下:

server {
    listen          80;
    server_name     frizio.local www.frizio.local;

    access_log      /var/log/nginx/static.access.log;
    error_log       /var/log/nginx/static.error.log;

    root /srv/http/static;


    location / {
            proxy_pass  http://localhost:8080/app-profile-jsp;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_redirect off;

            proxy_set_header    Host            $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 https;

    }


    location /pics {
            autoindex on;
            autoindex_exact_size off;
    }
}

当我尝试访问 (2) 时,服务器响应“404 not found”。

提前致谢

【问题讨论】:

    标签: java nginx wildfly


    【解决方案1】:

    我认为您错过了 proxypass 的尾随 /:

    proxy_pass  http://localhost:8080/app-profile-jsp/;
    

    另一件事,我认为您在这里不需要proxy_redirect off;

    希望对您有所帮助!

    【讨论】:

    • 非常感谢!!!另一个新手问题:我认为重定向存在问题,以管理我的 wildfly webapp 包含的页面。我有一个错误“无效参数:redirect_uri”.. 我想我会在配置文件的某些行中添加 $request_uri。不是吗?在哪里?
    • 您是否尝试过这样做:location / { proxy_pass http://localhost:8080/app-profile-jsp/; } 没有重定向,上游...只有 proxy_pass。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    • 2017-05-05
    相关资源
    最近更新 更多