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.

vhost.conf.j2 1.4KB

7 年之前
7 年之前
7 年之前
7 年之前
7 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. server {
  2. server_name {{ vhost.server_names | join(' ') }};
  3. listen 443 ssl;
  4. listen [::]:443 ssl;
  5. ssl_certificate /etc/ssl/certs/{{ certificate_name | default(vhost.certificate_name) | default(vhost.name) }}.fullchain.pem;
  6. ssl_certificate_key /etc/ssl/private/{{ certificate_name | default(vhost.certificate_name) | default(vhost.name) }}.key.pem;
  7. add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; ";
  8. charset utf-8;
  9. {% if vhost.try_files is defined %}
  10. try_files {{ vhost.try_files }};
  11. {% endif %}
  12. {% if vhost.locations is defined %}
  13. {% for loc in vhost.locations %}
  14. location {{ loc.location }} {
  15. {% if loc.proxy_pass is defined %}
  16. proxy_pass {{ loc.proxy_pass }};
  17. proxy_set_header Host $http_host;
  18. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  19. {% endif %}
  20. {% if loc.alias is defined %}
  21. alias {{ loc.alias }};
  22. {% endif %}
  23. {% if loc.try_files is defined %}
  24. try_files {{ loc.try_files }};
  25. {% endif %}
  26. {% if loc.redirect is defined %}
  27. return 301 {{ loc.redirect }};
  28. {% endif %}
  29. }
  30. {% endfor %}
  31. {% endif %}
  32. {% if vhost.root is defined %}
  33. root {{ vhost.root }};
  34. {% endif %}
  35. }
  36. server {
  37. listen 80;
  38. listen [::]:80;
  39. server_name {{ vhost.server_names | join(' ') }};
  40. location /.well-known/acme-challenge {
  41. default_type "text/plain";
  42. root /var/www/default;
  43. }
  44. location / {
  45. return 301 https://$host$request_uri;
  46. }
  47. }