Nginx将代理传递给url:http://example.com/test/app

时间:2015-10-21 16:57:44

标签: url nginx reverse-proxy

我正在尝试将Nginx配置为http://example.com/test/app

的代理

我的配置类似于:

class MyAction(argparse._StoreTrueAction):
    def __init__(self, *args, **kwargs):
        super(MyAction, self).__init__(*args,**kwargs)
        self.default=argparse.SUPPRESS
    def __call__(self, parser, namespace, values, option_string=None):
        setattr(namespace, 'flaga', True)
        setattr(namespace, 'flagb', True)

我得到了301回复。我不认为这是代理所指的网络应用程序,因为它的网址可以通过浏览器访问。

我对Nginx很新。请帮忙。 :)

1 个答案:

答案 0 :(得分:1)

请尝试以下最低配置:

server {

  listen 80;

  location / {

  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 $scheme;

  # Fix the "It appears that your reverse proxy set up is broken" error.
  proxy_pass          http://example.com/test/app;
  proxy_read_timeout  90;

  }
}

请注意,此示例中缺少安全方面。