我在私有子网中有一个网站,它在端口 8090 上使用 apache 2.4 运行,并在端口 80 上使用反向代理到 nginx 1.18,这意味着所有静态内容都由 nginx 运行,所有动态内容都由 apache 运行。我发现该网站的行为就像是不同 Web 服务器上的不同网站。我的观点是限制对 8090 的访问并将请求转发到 80。以下是配置:apache 虚拟主机
<VirtualHost 127.0.0.1>
ServerName gamingwiki.shprd.lan
ServerAlias www.gamingwiki.shprd.lan
ServerAdmin [email protected]
DocumentRoot /opt/wiki
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
端口配置文件
Listen 8090
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
nginx 网站.vhost
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name gamingwiki.shprd.lan;
#index doku.php index.html index.htm index.nginx-debian.html;
#forbid access to data,conf,bin,lib folders
location ~ /(data|conf|bin)/ {
deny all;
}
#forbid access to hidden files starts with .dot
location ~ /\. {
deny all;
#access_log off;
#log_not_found off;
}
# First attempt to serve requests as file, then as directory, then fall back to displaying a 404.
location / {
root /opt/wiki/;
proxy_pass http://127.0.0.1:8090/;
include /etc/nginx/proxy.conf;
#try_files $uri $uri/ =404;
}
}
这是 proxy.conf
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
``