| 1 |
#user awx; |
| 2 |
|
| 3 |
worker_processes 1; |
| 4 |
|
| 5 |
pid /tmp/nginx.pid; |
| 6 |
|
| 7 |
events { |
| 8 |
worker_connections 1024; |
| 9 |
} |
| 10 |
|
| 11 |
http { |
| 12 |
include /etc/nginx/mime.types; |
| 13 |
default_type application/octet-stream; |
| 14 |
server_tokens off; |
| 15 |
|
| 16 |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
| 17 |
'$status $body_bytes_sent "$http_referer" ' |
| 18 |
'"$http_user_agent" "$http_x_forwarded_for"'; |
| 19 |
|
| 20 |
access_log /dev/stdout main; |
| 21 |
|
| 22 |
map $http_upgrade $connection_upgrade { |
| 23 |
default upgrade; |
| 24 |
'' close; |
| 25 |
} |
| 26 |
|
| 27 |
sendfile on; |
| 28 |
#tcp_nopush on; |
| 29 |
#gzip on; |
| 30 |
|
| 31 |
upstream uwsgi { |
| 32 |
server 127.0.0.1:8050; |
| 33 |
} |
| 34 |
|
| 35 |
upstream daphne { |
| 36 |
server 127.0.0.1:8051; |
| 37 |
} |
| 38 |
|
| 39 |
{% if ssl_certificate is defined %} |
| 40 |
server { |
| 41 |
listen 8052 default_server; |
| 42 |
server_name _; |
| 43 |
|
| 44 |
# Redirect all HTTP links to the matching HTTPS page |
| 45 |
return 301 https://$host$request_uri; |
| 46 |
} |
| 47 |
{%endif %} |
| 48 |
|
| 49 |
server { |
| 50 |
{% if (ssl_certificate is defined) and (ssl_certificate_key is defined) %} |
| 51 |
listen 8053 ssl; |
| 52 |
|
| 53 |
ssl_certificate /etc/nginx/awxweb.pem; |
| 54 |
ssl_certificate_key /etc/nginx/awxweb_key.pem; |
| 55 |
{% elif (ssl_certificate is defined) and (ssl_certificate_key is not defined) %} |
| 56 |
listen 8053 ssl; |
| 57 |
|
| 58 |
ssl_certificate /etc/nginx/awxweb.pem; |
| 59 |
ssl_certificate_key /etc/nginx/awxweb.pem; |
| 60 |
{% else %} |
| 61 |
listen 8052 default_server; |
| 62 |
{% endif %} |
| 63 |
|
| 64 |
# If you have a domain name, this is where to add it |
| 65 |
server_name _; |
| 66 |
keepalive_timeout 65; |
| 67 |
|
| 68 |
# HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months) |
| 69 |
add_header Strict-Transport-Security max-age=15768000; |
| 70 |
|
| 71 |
# Protect against click-jacking https://www.owasp.org/index.php/Testing_for_Clickjacking_(OTG-CLIENT-009) |
| 72 |
add_header X-Frame-Options "DENY"; |
| 73 |
|
| 74 |
location /nginx_status { |
| 75 |
stub_status on; |
| 76 |
access_log off; |
| 77 |
allow 127.0.0.1; |
| 78 |
deny all; |
| 79 |
} |
| 80 |
|
| 81 |
location /static/ { |
| 82 |
alias /var/lib/awx/public/static/; |
| 83 |
} |
| 84 |
|
| 85 |
location /favicon.ico { alias /var/lib/awx/public/static/favicon.ico; } |
| 86 |
|
| 87 |
location /websocket { |
| 88 |
# Pass request to the upstream alias |
| 89 |
proxy_pass http://daphne; |
| 90 |
# Require http version 1.1 to allow for upgrade requests |
| 91 |
proxy_http_version 1.1; |
| 92 |
# We want proxy_buffering off for proxying to websockets. |
| 93 |
proxy_buffering off; |
| 94 |
# http://en.wikipedia.org/wiki/X-Forwarded-For |
| 95 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 96 |
# enable this if you use HTTPS: |
| 97 |
proxy_set_header X-Forwarded-Proto https; |
| 98 |
# pass the Host: header from the client for the sake of redirects |
| 99 |
proxy_set_header Host $http_host; |
| 100 |
# We've set the Host header, so we don't need Nginx to muddle |
| 101 |
# about with redirects |
| 102 |
proxy_redirect off; |
| 103 |
# Depending on the request value, set the Upgrade and |
| 104 |
# connection headers |
| 105 |
proxy_set_header Upgrade $http_upgrade; |
| 106 |
proxy_set_header Connection $connection_upgrade; |
| 107 |
} |
| 108 |
|
| 109 |
location / { |
| 110 |
# Add trailing / if missing |
| 111 |
rewrite ^(.*)$http_host(.*[^/])$ $1$http_host$2/ permanent; |
| 112 |
uwsgi_read_timeout 120s; |
| 113 |
uwsgi_pass uwsgi; |
| 114 |
include /etc/nginx/uwsgi_params; |
| 115 |
{%- if extra_nginx_include is defined %} |
| 116 |
include {{ extra_nginx_include }}; |
| 117 |
{%- endif %} |
| 118 |
proxy_set_header X-Forwarded-Port 443; |
| 119 |
uwsgi_param HTTP_X_FORWARDED_PORT 443; |
| 120 |
} |
| 121 |
} |
| 122 |
} |