【问题标题】:How to configure nginx to work with Jetty6 webserver?如何配置 nginx 以使用 Jetty6 网络服务器?
【发布时间】:2010-09-20 23:35:56
【问题描述】:

似乎nginx是和php、ruby、python一起使用的。

任何人都有一个如何设置 nginx 以在后端使用 jetty/tomcat 的示例?

谢谢。

【问题讨论】:

    标签: nginx jetty


    【解决方案1】:

    nginx 可以通过 HTTP 协议转发,因此只需将其指向正确的端口即可:

    server {
        location /anything {
            proxy_pass http://localhost:8080/whatever;
        }
    }
    

    【讨论】:

    • 谢谢。当您发布您的答案时,似乎我正在输入自己的答案。这是我第一次接触 nginx。谢谢。
    • 这不再是正确的答案了!截至目前(jetty9.3),您必须使用proxy_redirect off;,如下所示的@Florin。l
    【解决方案2】:

    没错。我想我有资格成为自学者,不是吗。

    只需在 nginx.conf 文件的 http { } 范围内添加这些行:

    server {
            listen          80;
            server_name     mydomain.com www.mydomain.com;
            access_log      /var/log/nginx_67_log main;
            location / {
                    proxy_pass      http://127.0.0.1:8080;
                    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;
            }
    }
    

    我现在必须尝试 gzip、SSL 和 dojo cometd,看看我是否可以升级到 nginx。 欢迎提供任何线索。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-27
      • 2018-02-07
      • 1970-01-01
      • 2016-03-14
      • 1970-01-01
      • 1970-01-01
      • 2015-11-16
      • 1970-01-01
      相关资源
      最近更新 更多