You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.3 KiB
98 lines
2.3 KiB
upstream backend_snipt { |
|
server 127.0.0.1:8000; |
|
} |
|
{% if pillar.env_name != 'vagrant' %} |
|
server { |
|
listen 80; |
|
server_name *.{{ pillar.hostname }}; |
|
|
|
if ($host ~* "^([^.]+(\.[^.]+)*)\.{{ pillar.hostname }}$"){ |
|
set $subd $1; |
|
rewrite ^(.*)$ https://$subd.{{ pillar.hostname }}$1 permanent; |
|
break; |
|
} |
|
} |
|
server { |
|
listen 80; |
|
server_name {{ pillar.hostname }} www.{{ pillar.hostname }} beta.{{ pillar.hostname }}; |
|
rewrite ^(.*) https://{{ pillar.hostname }}$1 permanent; |
|
} |
|
server { |
|
listen 443; |
|
server_name www.{{ pillar.hostname }}; |
|
|
|
ssl on; |
|
ssl_certificate /etc/certs/{{ pillar.hostname }}.crt; |
|
ssl_certificate_key /etc/certs/{{ pillar.hostname }}.key; |
|
|
|
rewrite ^(.*) https://{{ pillar.hostname }}$1 permanent; |
|
} |
|
server { |
|
listen 443; |
|
server_name {{ pillar.hostname }} *.{{ pillar.hostname }}; |
|
|
|
ssl on; |
|
ssl_certificate /etc/certs/{{ pillar.hostname }}.crt; |
|
ssl_certificate_key /etc/certs/{{ pillar.hostname }}.key; |
|
|
|
location ~* /favicon.ico { |
|
root /var/www/snipt/static/img/; |
|
expires max; |
|
} |
|
|
|
location / { |
|
rewrite_by_lua ' |
|
if string.find(ngx.var.host, "_") then |
|
local newHost, n = ngx.re.gsub(ngx.var.host, "_", "-") |
|
ngx.redirect(ngx.var.scheme .. "://" .. newHost .. ngx.var.uri) |
|
end |
|
'; |
|
proxy_pass http://backend_snipt; |
|
proxy_set_header Host $host; |
|
} |
|
|
|
location /static/ { |
|
alias /var/www/snipt/static/; |
|
expires max; |
|
} |
|
|
|
location /public/feed/ { |
|
rewrite ^/public/feed/$ https://{{ pillar.hostname }}/public/?rss permanent; |
|
} |
|
} |
|
server { |
|
listen 80 default_server; |
|
|
|
location / { |
|
proxy_pass http://backend_snipt; |
|
proxy_set_header Host $host; |
|
} |
|
|
|
location /static/ { |
|
alias /var/www/snipt/static/; |
|
expires max; |
|
} |
|
location ~* /favicon.ico { |
|
root /var/www/snipt/static/img/; |
|
expires max; |
|
} |
|
} |
|
{% else %} |
|
server { |
|
listen 80 default_server; |
|
|
|
location / { |
|
proxy_pass http://backend_snipt; |
|
proxy_set_header Host $host; |
|
} |
|
|
|
location /static/ { |
|
alias /var/www/snipt/media/; |
|
expires max; |
|
} |
|
location ~* /favicon.ico { |
|
root /var/www/snipt/media/img/; |
|
expires max; |
|
} |
|
} |
|
{% endif %}
|
|
|