configure nginx correctly

This commit is contained in:
Sebastian Hugentobler 2017-10-06 18:27:06 +02:00
parent 8ed45e959c
commit 78b3cc189b
2 changed files with 18 additions and 12 deletions

View File

@ -1,8 +1,8 @@
[Roundcube](https://roundcube.net/) webmail interface with postgres backend. [Roundcube](https://roundcube.net/) webmail interface with postgres backend.
# Environment Variables # Environment Variables
## DOMAIN ## DOMAINS
Space seperated list of domains to listen to. Semicolon seperated list of domains to listen to.
## DB_USER ## DB_USER
Name of the database user. Name of the database user.

View File

@ -18,29 +18,32 @@ http {
server 127.0.0.1:9000; server 127.0.0.1:9000;
} }
{{if (getenv "DOMAINS")}}
{{range $domain := split (getenv "DOMAINS") ";"}}
server { server {
listen 80; listen 80;
server_name {{ getenv "DOMAIN"}}; server_name {{ $domain }};
root /var/lib/roundcube; root /var/lib/roundcube;
index index.php index.html; index index.php index.html;
client_max_body_size 1G; client_max_body_size 1G;
add_header X-Clacks-Overhead "GNU Terry Pratchett"; add_header X-Clacks-Overhead "GNU Terry Pratchett";
location ~ ^/(data|config|\.ht|db_structure\.xml|README|AUTHORS|COPYING-AGPL|COPYING-README) { location ~ ^/(data|config|\.ht|db_structure\.xml|README|AUTHORS|COPYING-AGPL|COPYING-README) {
deny all; deny all;
} }
location / { location / {
try_files $uri $uri/ index.php; try_files $uri $uri/ index.php;
} }
location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ { location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
try_files $script_name = 404; try_files $script_name = 404;
include fastcgi_params; include fastcgi_params;
fastcgi_param PATH_INFO $path_info; fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
@ -48,10 +51,13 @@ http {
fastcgi_read_timeout 300; fastcgi_read_timeout 300;
fastcgi_pass php; fastcgi_pass php;
} }
location ~* ^.+.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { location ~* ^.+.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d; expires 30d;
access_log off; access_log off;
} }
} }
{{end}}
{{end}}
} }