我有一台先安装了 Apache 的服务器。随后我安装了 NGINX,以便将其反向代理到 Apache。根据 /etc/apache2/ports.conf,Apache 监听端口 8090
Listen 8090
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
当检查 /etc/nginx/sites-available/default 下的 NGINX 配置时,我发现服务器监听端口 80。我添加了另外五行(proxy_pass 和 proxy_set)以指定 NGINX 和 Apache 正在通信的 IP 地址和端口:
server {
listen 80 default_server;
listen [::]:80 default_server;
# root /var/www/html;
root /var/www/clients/client0/web1/web;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
proxy_pass http://MYIPADDRESS:8090;
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;
}
我已将其添加到 NGINX 文件中,如上所示,并添加到 apache 文件夹位置 /etc/apache2/sites-available/000-default.conf:
VirtualHost *:8090>
ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
DocumentRoot /var/www/clients/client0/web1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我的目标是显示我在此处另一个文件夹位置定义的索引页:/var/www/clients/client0/web1/web;