| Line 52: |
Line 52: |
| | } | | } |
| | </nowiki> | | </nowiki> |
| | + | |
| | + | == Example 1 == |
| | + | <nowiki>server { |
| | + | #connections on port 80 should be redirected to port 443 |
| | + | listen 80; |
| | + | server_name localhost; |
| | + | return 301 https://$host$request_uri; |
| | + | } |
| | + | |
| | + | server { |
| | + | #connections on port 443 should use ssl |
| | + | listen 443 ssl; |
| | + | server_name localhost; |
| | + | |
| | + | #specify the ssl certifcate and key file |
| | + | ssl_certificate /etc/ssl/certs/savvius.rra.lan.crt; |
| | + | ssl_certificate_key /etc/ssl/private/savvius.rra.lan.key; |
| | + | |
| | + | root /srv/insight/www; |
| | + | |
| | + | access_log /var/log/nginx/webconfig.ssl.access.log; |
| | + | error_log /var/log/nginx/webconfig.ssl.error.log; |
| | + | |
| | + | include fastcgi_params; |
| | + | |
| | + | #increase the max body size to support uploading system images |
| | + | client_max_body_size 1g; |
| | + | |
| | + | location / { |
| | + | #attempt to serve static files first |
| | + | #if that fails send request along to the webconfig app |
| | + | try_files $uri @webconfig; |
| | + | } |
| | + | |
| | + | location @webconfig { |
| | + | #don't cache content generated by the webconfig |
| | + | expires -1; |
| | + | fastcgi_read_timeout 3m; |
| | + | fastcgi_send_timeout 90m; |
| | + | fastcgi_pass unix:/tmp/insight.wsgi.sock; |
| | + | fastcgi_param GATEWAY_INTERFACE CGI/1.1; |
| | + | fastcgi_param QUERY_STRING $query_string; |
| | + | fastcgi_param REQUEST_METHOD $request_method; |
| | + | fastcgi_param CONTENT_TYPE $content_type; |
| | + | fastcgi_param CONTENT_LENGTH $content_length; |
| | + | fastcgi_param REQUEST_URI $request_uri; |
| | + | fastcgi_param DOCUMENT_URI $document_uri; |
| | + | fastcgi_param DOCUMENT_ROOT $document_root; |
| | + | fastcgi_param REMOTE_ADDR $remote_addr; |
| | + | fastcgi_param REMOTE_PORT $remote_port; |
| | + | fastcgi_param SERVER_PROTOCOL $server_protocol; |
| | + | fastcgi_param SERVER_NAME $server_name; |
| | + | fastcgi_param SERVER_PORT $server_port; |
| | + | fastcgi_param HTTPS on; |
| | + | } |
| | + | }</nowiki> |
| | + | |
| | + | == Example 2 == |
| | + | <nowiki>server { |
| | + | listen 8080; |
| | + | server_name localhost; |
| | + | return 301 https://$host:8443$request_uri; |
| | + | } |
| | + | |
| | + | server { |
| | + | listen 8443 ssl; |
| | + | server_name localhost; |
| | + | |
| | + | ssl_certificate /etc/ssl/certs/savvius.rra.lan.crt; |
| | + | ssl_certificate_key /etc/ssl/private/savvius.rra.lan.key; |
| | + | |
| | + | access_log /var/log/nginx/kibana.ssl.access.log; |
| | + | error_log /var/log/nginx/kibana.ssl.error.log; |
| | + | |
| | + | # TODO: decide on authentication |
| | + | auth_basic "Restricted Access"; |
| | + | auth_basic_user_file /etc/nginx/.htpasswd; |
| | + | |
| | + | location / { |
| | + | proxy_pass http://localhost:5601; |
| | + | proxy_http_version 1.1; |
| | + | proxy_set_header Upgrade $http_upgrade; |
| | + | proxy_set_header Connection 'upgrade'; |
| | + | proxy_set_header Host $host; |
| | + | proxy_cache_bypass $http_upgrade; |
| | + | proxy_read_timeout 300s; |
| | + | } |
| | + | }</nowiki> |
| | | | |
| | == Redirect HTTP to HTTPS == | | == Redirect HTTP to HTTPS == |