我正在运行一个CentOS7虚拟机,并尝试将其代理到Windows Server 2012上运行的亚音速服务器。当我使用Apache时,它工作没有问题,但我目前正在尝试使用nginx做同样的事情,但我保持getitng 502错误的网关。 我似乎无法确定是什么原因造成了这个问题。
我的nginx.conf:
server { listen 80; server_name *.example.com; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } server { listen 80; server_name music.exmaple.com; location / { proxy_pass http://192.168.1.67:6060/; proxy_redirect / http://192.168.1.67:6060/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 32 4k; }
}
在apache上:
<VirtualHost *:80> ServerName music.example.com ServerAlias www.music.example.com RewriteEngine on RewriteRule ^music/(.*)$ http://192.168.1.67:6060/ [P] ProxyPass / http://192.168.1.67:6060/ ProxyPassReverse / http://192.168.1.67:6060/ </VirtualHost>
Telnet到192.168.1.67:6060
Trying 192.168.1.67... Connected to 192.168.1.67. Escape character is '^]'. dir HTTP/1.1 400 Bad Request Connection: close Server: Jetty(8.yz-SNAPSHOT) Error: 400Connection closed by foreign host.
错误日志:
2014/10/23 16:51:21 [crit] 11191#0: *1 connect() to 192.168.1.67:6060 failed (13: Permission denied) while connecting to upstream, client: 192.168.1.1, server: music.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://192.168.1.67:6060/favicon.ico", host: "music.example.com"
任何帮助赞赏。 提前致谢。
默认情况下,SELinux阻止Web服务器与外部主机进行出站连接。
您可以通过设置httpd_can_network_connect布尔值来更改此设置并允许传出连接。
setsebool -P httpd_can_network_connect 1