diff --git a/dockerfiles/front/Dockerfile b/dockerfiles/front/Dockerfile index 9e9b705..3b321f0 100644 --- a/dockerfiles/front/Dockerfile +++ b/dockerfiles/front/Dockerfile @@ -13,6 +13,7 @@ RUN npx ng build FROM nginx:alpine COPY --from=build /app/dist/tlcfront /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/dockerfiles/front/nginx.conf b/dockerfiles/front/nginx.conf new file mode 100644 index 0000000..d152c82 --- /dev/null +++ b/dockerfiles/front/nginx.conf @@ -0,0 +1,20 @@ +server { + location /api/polls { + proxy_pass http://back:8080; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html?$args; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/dockerfiles/nginx/nginx.conf b/dockerfiles/nginx/nginx.conf index 3c9d636..95a0fe6 100644 --- a/dockerfiles/nginx/nginx.conf +++ b/dockerfiles/nginx/nginx.conf @@ -1,5 +1,9 @@ +########################## +## FRONTEND + API +########################## server { listen 80; + listen [::]:80; server_name _; root /usr/share/nginx/html; @@ -8,8 +12,8 @@ server { ########################## # Proxy API requests to the back service ########################## - location /api/ { - proxy_pass http://back:8080/api/; + location /api/polls { + proxy_pass http://back:8080/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -21,6 +25,51 @@ server { # FrontEnd returns ########################## location / { - try_files $uri $uri/ /index.html; + proxy_pass http://front:5080; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Connection ""; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} + +## +## BACKEND +## +server { + listen 80; + listen [::]:80; + server_name _; + + location / { + proxy_pass http://back:8080; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + } +} + +## +## ETHERPAD +## +server { + listen 80; + listen [::]:80; + server_name _; + + location / { + proxy_pass http://etherpad:9001; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; } }