【问题标题】:NGINX Proxy PassNGINX 代理通行证
【发布时间】:2017-03-17 10:05:18
【问题描述】:

我有一台运行 NGINX 的主服务器和一台运行 Apache/cPanel 的第二台服务器。

我们正在尝试做的是让我们的微型网站与主服务器分开。微站主要是Wordpress

我遇到的问题是我们希望它们具有http://example.com/path 的域格式。

但是,我注意到使用下面的proxy_pass 不适用于多个站点。

还建议我将微型网站变成第二台服务器上的子域,以缓解proxy_pass 的混乱 - path.example.com

然后我遇到了如何让http://example.com/path 镜像path.example.com 并像http://example.com/path 一样工作的问题

目前它可以通过使用下面的方法来半工作,但是 /private 只加载 /blog

配置:

location /blog/ {
  include proxy-pass-settings.conf;
  proxy_pass http://blogging.example.com/;
}

location /private/ {
  include proxy-pass-settings.conf;
  proxy_pass  http://blogging.example.com/;

代理配置:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;

【问题讨论】:

  • 请包含proxy-pass-settings.conf。
  • @TanHongTat 完成 :)
  • /blog/ 和 /private/ 在 http://blogging.example.com/ 上的真实路径是什么?是http://blogging.example.com/blog/ 和http://blogging.example.com/private/ 吗?
  • @TanHongTat 应该是 example.com/blog example.com/private

标签: apache nginx proxypass


【解决方案1】:

试试这个:

location ^~ /blog/ {
  include proxy-pass-settings.conf;
  proxy_pass http://blogging.example.com;
}

location ^~ /private/ {
  include proxy-pass-settings.conf;
  proxy_pass  http://blogging.example.com;
}

如果 proxy_pass 没有指定 URI,则请求 URI 在处理原始请求时以与客户端发送的相同格式传递给服务器,或者在处理更改的 UR 时传递完整的规范化请求 URI。

来源:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-04
    • 2016-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-05
    • 2020-08-02
    • 2020-05-05
    相关资源
    最近更新 更多