diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 00000000..6f3567a8 --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:latest + +RUN rm /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 00000000..605647bc --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,69 @@ +upstream fetwebsite { + server django-homepage:8000; +} + +upstream etherpadwebsite { + server etherpad:9001; +} + +server { + listen 80; + + # server_name localhost; + + # Logging + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + + # Handles all other requests + location / { + # Forward requests to Django application + proxy_pass http://fetwebsite; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_redirect off; + } + + location /files { + alias /usr/src/app/files/; + } + + # location /files/uploads/finance { + # auth_request /auth; + + # # error_page 401 = @error401; + # } + + # location = /auth { + # proxy_pass http://fetwebsite/auth/login/; + # proxy_pass_request_body off; + # proxy_set_header Content-Length ""; + # proxy_set_header X-Original-URI $request_uri; + # } + + # location @error401 { + # set $query ''; + # if ($request_uri ~* "[^\?]+\?(.*)$") { + # set $query $1; + # } + + # return 302 /login/?next=$scheme://$http_host$http_port$request_uri; + # } + + location /etherpad { + rewrite /etherpad/(.*) /$1 break; + rewrite ^/etherpad$ /etherpad/ permanent; + proxy_pass http://etherpadwebsite; + proxy_redirect / /etherpad/; + + proxy_set_header Host $host; + proxy_buffering off; + + # Header weiterleiten + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header X-Forwarded-Host $host; + } + +}