]> git.evergreen-ils.org Git - OpenSRF.git/blob - examples/nginx/osrf-ws-http-proxy
e539013f56a9b536c1f44d6f19689658a303cd02
[OpenSRF.git] / examples / nginx / osrf-ws-http-proxy
1 # File /etc/nginx/sites-available/osrf-ws-http-proxy
2 #
3 # $ ln -s /etc/nginx/sites-available/osrf-ws-http-proxy \
4 #   /etc/nginx/sites-enabled/osrf-ws-http-proxy
5 # $ sudo service nginx restart
6 #
7 # Assumes Apache is listening on HTTP=7080 and HTTPS=7443
8
9 # Example sending nginx logs to syslog
10 # error_log  syslog:server=unix:/dev/log,nohostname;
11 # access_log syslog:server=unix:/dev/log,severity=info,nohostname combined;
12
13 server { 
14     listen 80;
15
16     # For SSL-everywhere:
17     # server_name domain.example.org
18     # return 301 https://domain.example.org$request_uri;
19
20     location / {
21         proxy_pass http://localhost:7080;
22         proxy_set_header Host $host;
23         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
24         proxy_set_header X-Forwarded-Proto $scheme;
25         proxy_read_timeout 300s;
26     }
27 }
28
29 server {
30     listen 443 ssl http2;
31
32     # Use the same SSL certificate as Apache.
33     ssl_certificate /etc/apache2/ssl/server.crt;
34     ssl_certificate_key /etc/apache2/ssl/server.key;
35
36     # -----------------------------------------------------------------
37     # https://mozilla.github.io/server-side-tls/ssl-config-generator/
38     # generate with openssl dhparam -out dhparams.pem 2048
39     ssl_dhparam /etc/apache2/ssl/dhparam.pem;
40     ssl_session_timeout 1d;
41     ssl_session_cache shared:SSL:50m;
42     ssl_session_tickets off;
43     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
44     # Intermediate ciphers config / updated 2018-07-11
45     ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
46     ssl_prefer_server_ciphers on;
47     # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
48     add_header Strict-Transport-Security max-age=15768000;
49     # OCSP Stapling ---
50     # fetch OCSP records from URL in ssl_certificate and cache them
51     ssl_stapling on;
52     ssl_stapling_verify on;
53     # -----------------------------------------------------------------
54
55     location / {
56         proxy_pass https://localhost:7443;
57         proxy_set_header Host $host;
58         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
59         proxy_set_header X-Forwarded-Proto $scheme;
60         proxy_read_timeout 300s;
61     }
62
63     location /osrf-websocket-translator {
64
65         # websocketd may be run with or without SSL.  When used with
66         # NGINX, the assumption is it runs w/o SSL.  Change to taste.
67         proxy_pass http://localhost:7682;
68
69         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
70
71         # Needed for websockets proxying.
72         proxy_http_version 1.1;
73         proxy_set_header Upgrade $http_upgrade;
74         proxy_set_header Connection "upgrade";
75
76         # Disconnect the client if it takes this long to connect to
77         # websocketd.
78         proxy_connect_timeout 1m;
79
80         # websocketd connections persist indefinitely. Leverage 
81         # nginx timeouts to disconnect idle clients.  Change
82         # to taste.
83         proxy_send_timeout 3m;
84         proxy_read_timeout 3m;
85     }
86 }
87
88