NGINX 代理通行证
NGINX Proxy Pass
我有一个主服务器 运行ning NGINX 和第二个服务器 运行ning 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;
试试这个:
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;
}
If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed UR.
来源:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
我有一个主服务器 运行ning NGINX 和第二个服务器 运行ning 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;
试试这个:
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;
}
If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed UR.
来源:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass