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') conftmpl = _get_template('vhost.nginx')
confdata = conftmpl.render( confdata = conftmpl.render(domain=sitename, wildcard=wildcard)
domain=sitename, user=username,
docroot=_build_document_root_path(sitename, username),
wildcard=wildcard)
conffile = None conffile = None
try: try:
nginxtemp, filename = mkstemp() nginxtemp, filename = mkstemp()

View file

@ -1,31 +1,23 @@
server { server {
server_name {{ domain }}; {% if wildcard -%}
{%- if wildcard %} server_name .{{ domain|parentdomain }};
server_name *.{{ domain|parentdomain }}; {% else -%}
{%- endif %} server_name {{ domain }};
{% -endif %}
listen [::]:80; listen 80;
listen [::]:80;
access_log /var/log/nginx/{{ domain }}.access.log; access_log /var/log/nginx/{{ domain }}.access.log;
error_log /var/log/nginx/{{ domain }}.error.log; error_log /var/log/nginx/{{ domain }}.error.log;
client_max_body_size 20M; location /.well-known/acme-challenge {
gzip on; root /srv/www/acme-challenge/{{ domain }};
gzip_types text/javascript application/x-javascript text/css; }
root {{ docroot }}; location / {
return 301 https://$host$request_uri;
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 ~ /\.ht {
deny all;
}
} }
# vim: ft=nginx et sw=4 ts=4 si ai