nc.jinja.conf 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. {% macro opcache(values) -%}
  2. opcache.interned_strings_buffer={{ values.nextcloud.op_cache_interned_strings_buffer }}
  3. opcache.memory_consumption={{ values.nextcloud.op_cache_memory_consumption }}
  4. {%- endmacro -%}
  5. {% macro php(values) -%}
  6. max_execution_time={{ values.nextcloud.max_execution_time }}
  7. {%- endmacro -%}
  8. {% macro limit_request_body(values) -%}
  9. {%- set bytes_gb = 1024 * 1024 * 1024 -%}
  10. LimitRequestBody {{ values.nextcloud.php_upload_limit * bytes_gb }}
  11. {%- endmacro -%}
  12. {% macro use_x_real_ip_in_logs() -%}
  13. {# `(%{X-Real-IP}i)` is added after each LogFormat `%h` statement from /etc/apache2/apache2.conf -#}
  14. LogFormat "%v:%p %h (%{X-Real-IP}i) %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
  15. LogFormat "%h (%{X-Real-IP}i) %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
  16. LogFormat "%h (%{X-Real-IP}i) %l %u %t \"%r\" %>s %O" common
  17. {%- endmacro -%}
  18. {% macro nginx_conf(values) -%}
  19. {%- set port = namespace(x=":$server_port") -%}
  20. {%- if values.network.nginx.use_different_port -%}
  21. {%- set port.x = ":%d"|format(values.network.nginx.external_port) -%}
  22. {%- endif -%}
  23. {%- if port.x == ":443" -%}
  24. {%- set port.x = "" -%}
  25. {%- endif -%}
  26. events {}
  27. http {
  28. server {
  29. listen {{ values.network.web_port.port_number }} ssl;
  30. listen [::]:{{ values.network.web_port.port_number }} ssl;
  31. http2 on;
  32. # Redirect HTTP to HTTPS
  33. error_page 497 301 =307 https://$host{{ port.x }}$request_uri;
  34. ssl_certificate {{ values.consts.ssl_cert_path }};
  35. ssl_certificate_key {{ values.consts.ssl_key_path }};
  36. client_max_body_size {{ values.nextcloud.php_upload_limit }}G;
  37. add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" always;
  38. location = /robots.txt {
  39. allow all;
  40. log_not_found off;
  41. access_log off;
  42. }
  43. location ^~ /.well-known {
  44. # The rules in this block are an adaptation of the rules
  45. # in `.htaccess` that concern `/.well-known`.
  46. location = /.well-known/carddav { return 301 /remote.php/dav/; }
  47. location = /.well-known/caldav { return 301 /remote.php/dav/; }
  48. location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
  49. location /.well-known/pki-validation { try_files $uri $uri/ =404; }
  50. # Let Nextcloud's API for `/.well-known` URIs handle all other
  51. # requests by passing them to the front-end controller.
  52. return 301 /index.php$request_uri;
  53. }
  54. location / {
  55. proxy_pass http://{{ values.consts.nextcloud_container_name }}:80;
  56. proxy_http_version 1.1;
  57. proxy_cache_bypass $http_upgrade;
  58. proxy_request_buffering off;
  59. # Proxy headers
  60. proxy_set_header Upgrade $http_upgrade;
  61. proxy_set_header Connection "upgrade";
  62. proxy_set_header Host $http_host;
  63. proxy_set_header X-Real-IP $remote_addr;
  64. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  65. proxy_set_header X-Forwarded-Proto https;
  66. proxy_set_header X-Forwarded-Host $host;
  67. proxy_set_header X-Forwarded-Port {{ port.x | default("443", true) | replace(":", "") }};
  68. # Proxy timeouts
  69. proxy_connect_timeout {{ values.network.nginx.proxy_timeout }}s;
  70. proxy_send_timeout {{ values.network.nginx.proxy_timeout }}s;
  71. proxy_read_timeout {{ values.network.nginx.proxy_timeout }}s;
  72. }
  73. include /etc/nginx/includes/*.conf;
  74. }
  75. }
  76. {%- endmacro -%}