SHARE
TWEET

nginx conf

igorhmm Sep 19th, 2014 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ssl_certificate      /web/certificates/mydomain.com.pem;
  2. ssl_certificate_key  /web/certificates/mydomain.com.key;
  3.  
  4. # Web server
  5. #
  6. server {
  7.     listen              80;
  8.     listen              443 ssl;
  9.     server_name         www.mydomain.com;
  10.  
  11.     location / {
  12.       root      /web/htdocs/www.mydomain.com;
  13.       include   php.conf;
  14.       include   block-hidden.conf;
  15.     }
  16. }
  17.  
  18. # Websocket
  19. #
  20. upstream websocketpool {
  21.   ip_hash; # Clients with the same IP are redirected to the same backend
  22.  
  23.   server 10.0.0.60:9000  fail_timeout=20s weight=1; # id=web-01
  24.   server 10.0.0.250:9000 fail_timeout=20s weight=1; # id=web-02
  25.   server 10.0.0.152:9000 fail_timeout=20s weight=1; # id=web-03
  26. }
  27.  
  28. server {
  29.   listen        80;
  30.   listen        443 ssl;
  31.   server_name   ws.mydomain.com 10.*;
  32.   access_log    /var/log/nginx/ws.mydomain.com.access.log  main;
  33.  
  34.   location / {
  35.     proxy_pass http://websocketpool;
  36.     proxy_http_version 1.1;
  37.     proxy_set_header Upgrade $http_upgrade;
  38.     proxy_set_header Connection $connection_upgrade;
  39.     proxy_set_header Host $host;
  40.     proxy_set_header X-Real-IP $remote_addr;
  41.     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  42.     proxy_set_header X-Forwarded-Proto $scheme;
  43.     proxy_set_header X-NginX-Proxy true;
  44.     proxy_redirect off;
  45.     error_page 500 502 /error/500.html;
  46.   }
  47. }
RAW Paste Data
Top