add nginx.conf for frontend

This commit is contained in:
tuanvu
2026-02-12 10:56:08 +01:00
parent 1c3ee99b74
commit 20d83ffafe
3 changed files with 73 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ RUN npx ng build
FROM nginx:alpine FROM nginx:alpine
COPY --from=build /app/dist/tlcfront /usr/share/nginx/html COPY --from=build /app/dist/tlcfront /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80 EXPOSE 80

View File

@@ -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;
}
}

View File

@@ -1,5 +1,9 @@
##########################
## FRONTEND + API
##########################
server { server {
listen 80; listen 80;
listen [::]:80;
server_name _; server_name _;
root /usr/share/nginx/html; root /usr/share/nginx/html;
@@ -8,8 +12,8 @@ server {
########################## ##########################
# Proxy API requests to the back service # Proxy API requests to the back service
########################## ##########################
location /api/ { location /api/polls {
proxy_pass http://back:8080/api/; proxy_pass http://back:8080/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@@ -21,6 +25,51 @@ server {
# FrontEnd returns # FrontEnd returns
########################## ##########################
location / { 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;
} }
} }