1. 本机(记作主机A)安装了Windows版本的nginx,配置文件内容如下:
worker_processes 4;
#pid logs/nginx.pid;
events
{
worker_connections 1024;
}
http
{
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream server2
{
server a4.chinaunix weight=1 max_fails=2 fail_timeout=30;
}
server
{
listen 80;
server_name 127.0.0.1;
location /A4Hello
{
proxy_pass http://server2;
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 4k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#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 html;
}
}
}
2. 域名a4.chinaunix对应2个IP,分别是10.1.1.1和10.1.1.2,该机器记作B;
3. 想从主机A上访问主机B上的IIS站点A4Hello
(1)在主机A的HOSTS文件中配置了10.1.1.1 a4.chinaunix
(2)在主机A的浏览器中输入http://localhost/A4Hello,报错:
An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later.
If you are the system administrator of this resource then you should check the error log for details.
Faithfully yours, nginx.
查看日志中显示:2016/10/11 14:32:26 [error] 3212#2404: *57 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /A4Portal/ HTTP/1.1", upstream: "http://10.1.1.1:80/A4Hello/", host: "localhost"
请问是nginx配置文件哪些错了呢?谢谢!
1K+ 阅读
有没有试过改成这样:
upstream server2
{
server 10.1.1.1 weight=1 max_fails=2 fail_timeout=30;
server 10.1.1.2 weight=1 max_fails=2 fail_timeout=30;
}
server 10.1.1.1 weight=1 max_fails=2 fail_timeout=30;
server 10.1.1.2 weight=1 max_fails=2 fail_timeout=30;
}
server {
listen 80;
server_name a4.chinaunix;