我正在运行 nginx 作为反向代理,并希望为在 apache2 服务器上运行的应用程序提供服务。apache2 服务器上的应用程序正在运行,可通过以下方式获取http://192.168.102:8080/但是当我尝试通过 nginx 代理访问时总是出现 Bad Gateway 错误。
nginx 配置
server {
listen 443 ssl http2; listen [::]:443 ssl http2;
server_name tools.domain.net; access_log /var/log/nginx/access.log;
client_max_body_size 100M; large_client_header_buffers 8 32k;
location /cctool/ {
proxy_pass http://192.168.62.102:8080/;
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;
proxy_set_header X-Forwarded-Host $host:443;
proxy_set_header X-Forwarded-Server $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
apache2 主机配置
<Directory /var/www/tools.domain.net>
AllowOverride None
Require all denied
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www/clients/client1/web3/web
ServerName tools.domain.net
ServerAdmin [email protected]
ErrorLog /var/log/ispconfig/httpd/tools.domain.net/error.log
WSGIDaemonProcess cctool
WSGIScriptAlias /cctool/ /var/www/support.domain.net/cctool/cctool.wsgi
<Directory /var/www/support.domain.net/cctool/>
WSGIProcessGroup cctool
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Require all granted
Allow from all
</Directory>
</VirtualHost>
nginx 错误日志
2018/12/13 15:03:51 [error] 18695#18695: *5487204 upstream prematurely closed connection while reading response header from upstream, client: 192.168.10.91, server: tools.domain.net, request: "GET /cctool/ HTTP/1.1", upstream: "http://192.168.62.102:80/cctool/", host: "tools.domain.net"