带有SSL的websockets的nginx反向代理

我想在我的osx开发机器上configurationnginx(通过macports安装)。 我试图将代理本地主机:12346 /交易到一个websocket连接,可以在远程机器上的/ trade在端口12346上使用。

我正在使用下面的nginx.conf文件。 它在SSL SECTION被注释掉的时候有效,但是nginx在未注释的时候不能正常启动。 我已经在其他问题和答案这里,从其他网站build模conf文件。 我已经尝试了20种不同的方式,但只要取消注释任何SSL相关的行,nginx就不会启动。

worker_processes 1; events { worker_connections 20; } error_log /opt/local/etc/nginx/debug.log debug; http { include mime.types; default_type application/octet-stream; # # Some default configuration. # sendfile on; tcp_nopush on; keepalive_timeout 65; # # A list with load balancing backends hashed on IP for sticky load balancing. # upstream backend { # ip_hash; server 123.456.78.90:12346; } server { listen 12346; # ssl used here when un-commented server_name localhost; # SSL SECTION # ssl on; # ssl_certificate /opt/local/etc/nginx/server.crt; # ssl_certificate_key /opt/local/etc/nginx/server.key; # ssl_session_cache builtin:1000 shared:SSL:10m; # # ssl_session_timeout 5m; # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; # ssl_prefer_server_ciphers on; # END SSL SECTION # # Proxy settings # location /trade { proxy_pass http://backend/; proxy_redirect off; 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; # WebSocket specific proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # # Specific for comet or long running HTTP requests, don't buffer up the # response from origin servers but send them directly to the client. # proxy_buffering off; # # Bump the timeout's so someting sensible so our connections don't # disconnect automatically. We've set it to 12 hours. # proxy_connect_timeout 43200000; proxy_read_timeout 43200000; proxy_send_timeout 43200000; } } } 

任何人都可以发现我做错了什么?

弄清楚了。 有了Macports,你必须使用sudo port install nginx +ssl明确地安装带有ssl支持的sudo port install nginx +ssl笨蛋,我知道 – 为什么你不安装它,为什么你的标志是以+开头的…