【发布时间】:2020-05-19 17:07:30
【问题描述】:
我一直在尝试使用 Nginx 作为 Apache 的反向代理进行设置,但无济于事,我的大脑开始融化。我正在运行一个 CentOS 8 系统,Apache 配置为仅侦听端口 8080。我有一个 Apache 虚拟主机配置如下:
<VirtualHost *:8080>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/user/public_html/example.com
<Directory /home/user/public_html/example.com>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/example.com-error.log
CustomLog /var/log/httpd/example.com.log combined
</VirtualHost>
Nginx 充当反向代理并侦听 HTTP 和 HTTPS 连接并代理与 Apache 的连接。 domain.com 包含一个 PHP 应用程序 (Laravel)。我有以下 Nginx 的服务器配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name example.com www.example.com;
root /home/user/public_html/example.com;
index index.php index.html index.htm;
ssl on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 60m;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=16000000;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
#proxy_redirect off;
}
location ~ /\.ht {
deny all;
}
}
非常感谢任何帮助。我无法加载应用程序,所有请求都返回 ERR_TOO_MANY_REDIRECTS。
【问题讨论】:
标签: apache http nginx https nginx-reverse-proxy