Writes configuration files for nginx based on running services and certificates
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

nginx.tpl 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {% for srvname, service in services.items() %}
  2. upstream {{ service.upstream }} {
  3. {% for upstream in service.hosts %}
  4. server {{ upstream.host }}:{{ upstream.port }};
  5. {% endfor %}
  6. }
  7. server {
  8. server_name {{ ' '.join(service.vhosts) }};
  9. listen [::]:443{{ ' default_server' if service.default }} ssl http2;
  10. listen 443{{ ' default_server' if service.default }} ssl http2;
  11. ssl_certificate {{ service.certificate }};
  12. ssl_trusted_certificate {{ service.trusted_certificate }};
  13. ssl_certificate_key {{ service.certificate_key }};
  14. include /etc/nginx/conf.d/{{ service.vhosts[0] }}/*.conf;
  15. # From https://community.letsencrypt.org/t/how-to-nginx-configuration-to-enable-acme-challenge-support-on-all-http-virtual-hosts/5622
  16. location ^~ /.well-known/acme-challenge/ {
  17. default_type "text/plain";
  18. alias {{ wellknown_path }};
  19. }
  20. # Hide /acme-challenge subdirectory and return 404 on all requests.
  21. # It is somewhat more secure than letting Nginx return 403.
  22. # Ending slash is important!
  23. location = /.well-known/acme-challenge/ {
  24. return 404;
  25. }
  26. location / {
  27. proxy_pass {{ service.protocol }}://{{ service.upstream }};
  28. proxy_set_header Host $host;
  29. proxy_set_header X-Forwarded-For $remote_addr;
  30. proxy_set_header X-Forwarded-Proto $scheme;
  31. }
  32. }
  33. {% endfor %}