Change nginx vhost template

This commit reduces the nginx vhost template to the bare minimum needed
to get a vhost that can be used to get a certificate via letsencrypt's
certbot.
This commit is contained in:
Jan Dittberner 2020-02-29 12:02:32 +01:00
parent 4f396c606f
commit de322b3442
2 changed files with 18 additions and 29 deletions

View file

@ -77,10 +77,7 @@ def create_web_vhost_config(username, sitename, wildcard):
"""
conftmpl = _get_template('vhost.nginx')
confdata = conftmpl.render(
domain=sitename, user=username,
docroot=_build_document_root_path(sitename, username),
wildcard=wildcard)
confdata = conftmpl.render(domain=sitename, wildcard=wildcard)
conffile = None
try:
nginxtemp, filename = mkstemp()

View file

@ -1,31 +1,23 @@
server {
{% if wildcard -%}
server_name .{{ domain|parentdomain }};
{% else -%}
server_name {{ domain }};
{%- if wildcard %}
server_name *.{{ domain|parentdomain }};
{% -endif %}
listen 80;
listen [::]:80;
access_log /var/log/nginx/{{ domain }}.access.log;
error_log /var/log/nginx/{{ domain }}.error.log;
client_max_body_size 20M;
gzip on;
gzip_types text/javascript application/x-javascript text/css;
root {{ docroot }};
index index.php index.html index.htm;
location ~ ^/(.+\.php)$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm-{{ user }}.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
location /.well-known/acme-challenge {
root /srv/www/acme-challenge/{{ domain }};
}
location ~ /\.ht {
deny all;
location / {
return 301 https://$host$request_uri;
}
}
# vim: ft=nginx et sw=4 ts=4 si ai