diff --git a/server/nginx.conf b/server/nginx.conf index 059e16d..28cbfc3 100644 --- a/server/nginx.conf +++ b/server/nginx.conf @@ -5,15 +5,24 @@ upstream app_server { server { listen 80; server_name dpaste.de dpaste.org; - include /srv/dpaste.de/src/dpaste/server/nginx_server.conf; + + # Do not redirect to SSL for API calls (some clients dont support + # this automatically) + location /api { + include /srv/dpaste.de/src/dpaste/server/nginx_server_appforward.conf; + } + + location / { + rewrite ^ https://$server_name$request_uri? permanent; + } } server { listen 443; server_name dpaste.de; ssl on; - ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; - ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; + ssl_certificate /srv/dpaste.de/var/ssl/dpaste_de_unified.crt; + ssl_certificate_key /srv/dpaste.de/var/ssl/dpaste_de.key; include /srv/dpaste.de/src/dpaste/server/nginx_server.conf; } @@ -22,8 +31,8 @@ server { listen 443; server_name dpaste.org; ssl on; - ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; - ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; + ssl_certificate /srv/dpaste.de/var/ssl/dpaste_org_unified.crt; + ssl_certificate_key /srv/dpaste.de/var/ssl/dpaste_org.key; include /srv/dpaste.de/src/dpaste/server/nginx_server.conf; } diff --git a/server/nginx_server.conf b/server/nginx_server.conf index 98a2aa6..a29676b 100644 --- a/server/nginx_server.conf +++ b/server/nginx_server.conf @@ -1,21 +1,15 @@ - server_name dpaste.de dpaste.org; - error_log /srv/dpaste.de/var/nginx.error.log; keepalive_timeout 5; client_max_body_size 4G; + location /media/ { alias /srv/dpaste.de/var/media/; } + location /static/ { alias /srv/dpaste.de/var/static/; } + location / { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_buffering off; - if (!-f $request_filename) { - proxy_pass http://app_server; - break; - } + include /srv/dpaste.de/src/dpaste/server/nginx_server_appforward.conf; } diff --git a/server/nginx_server_appforward.conf b/server/nginx_server_appforward.conf new file mode 100644 index 0000000..ab287fd --- /dev/null +++ b/server/nginx_server_appforward.conf @@ -0,0 +1,8 @@ + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + proxy_buffering off; + if (!-f $request_filename) { + proxy_pass http://app_server; + break; + }