【发布时间】:2025-12-01 15:30:02
【问题描述】:
我正在寻找一些提示如何做我目前想做的事情。
这是我应该做的: Nginx 服务器代理 (srvrp) -> Apache2 (srvdeba)
这里是 nginx 网站 srvrp 的配置:
server {
server_name www.egloff-j-quest-etna.nx;
location / {
proxy_pass http://srvdeba.egloff-j-quest-etna.nx;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $proxy_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
}
}
这是启用 srvdeba 站点的网站的配置:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.srvdeba.egloff-j-quest-etna.nx
ServerAlias *srvdeba.egloff-j-quest-etna.nx
DocumentRoot /opt/wordpress
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /opt/wordpress/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
目前,这是可行的,但并非完全可行,问题如下: 当网站通过代理加载时,网站上的所有链接都采用这种形式: http://srvdeba.egloff-j-quest-etna.nx 我希望它们对应于: www.egloff-j-quest-etna.nx
所以,我想出了两个解决方案,第一个是使用 ngx_http_sub_module 第二个是配置apache2,这样他就知道自己被代理了,并且可以在通过代理服务器完成请求时重写URL。 srvdeba 在没有代理服务器的情况下访问时必须工作。 所以我需要你告诉我什么是最好的解决方案!
提前感谢您的回答。
【问题讨论】:
-
好吧,我尝试了 ngx_http_sub_module,但它根本不起作用。也许我做错了什么。现在我将尝试配置 apache2。
标签: nginx apache2 url-routing reverse-proxy