我有2台服务器A和B,在服务器A上安装了nginx 下面是我在/etc/nginx/nginx.conf中配置的配置文件,配置如下
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
upstream sendforward {
server Server_IP_B:9000;
}
server {
#access_log off;
server_name my_server_name;
listen 443;
large_client_header_buffers 4 16k;
error_log /var/log/nginx/error.log;
location / {
proxy_pass http://sendforward;
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_redirect off;
}
}
}
当我在端口443上向服务器A发送消息时,它会写入“access_log”文件,但不会将消息转发给服务器B. 我还通过ubuntu命令'nc -l 9000'和wireshark检查过滤'tcp.port == 9000'。
我不明白为什么会这样,或者我是否会错过配置。
提前致谢。
答案 0 :(得分:0)
您是否尝试在代理通过之前定义上游?
我也认为你应该删除你的proxypass的斜杠 所以http://sendforward代替http://sendforward/