30 lines
825 B
Django/Jinja
30 lines
825 B
Django/Jinja
server {
|
|
# serve website on port 80
|
|
listen [::]:80;
|
|
listen 80;
|
|
|
|
# write error logs to file
|
|
error_log /var/log/nginx/{{ hostname }}.error.log;
|
|
# write access logs to file
|
|
access_log /var/log/nginx/{{ hostname }}.access.log;
|
|
|
|
# serve only on this domain:
|
|
server_name {{ hostname }};
|
|
|
|
# use files from this directory
|
|
root {{ path }};
|
|
|
|
# remove .html from URL; it is cleaner this way
|
|
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
|
|
|
|
{% if redirects %}
|
|
{% for redirect in redirects %}
|
|
rewrite ^/{{redirect.from}}$ /{{ redirect.to }} redirect;
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
# when a request is received, try the index.html in the directory
|
|
# or $uri.html
|
|
try_files $uri/index.html $uri.html $uri/ $uri =404;
|
|
}
|