我试图找到如何将nginx配置为客户端和应用服务器之间的反向代理。最初使用http和通过端口44444进行Web套接字连接的应用服务器和客户端,我想添加代理以使用HTTPS协议:(this picture)
这是我的配置文件的外观,但是我总是收到错误消息“ Web套接字连接被拒绝”
server {
listen 80;
server_name 192.168.72.100;
return 301 https://192.168.72.100;
}
server {
listen 44444;
server_name 192.168.72.100;
set $upstream 192.168.72.73;
location / {
proxy_pass ws://$upstream:44444/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
server {
listen 443 ;
server_name 192.168.72.100;
# SSL config
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 4h;
access_log /temp/nginx/log/access.log;
error_log /temp/nginx/log/error.log error;
set $upstream 192.168.72.73;
location / {
proxy_pass http://$upstream;
proxy_buffering Off;
proxy_cache_valid 404 3h;
proxy_cache_valid 500 502 504 406 3h;
proxy_cache_valid 200 6h;
proxy_buffers 600 100m;
proxy_busy_buffers_size 512m;
proxy_buffer_size 200m;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
proxy_cache_key "$host$request_uri";
proxy_ignore_headers Set-Cookie;
proxy_cache_min_uses 3;
proxy_max_temp_file_size 0;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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 450m;
client_body_buffer_size 300m;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_ignore_client_abort off;
proxy_intercept_errors off;
proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment;
proxy_cache_bypass $http_pragma $http_authorization;
}
}
任何帮助将不胜感激!