error with etherpad

This commit is contained in:
tuanvu
2026-02-12 12:23:47 +01:00
parent 20d83ffafe
commit d8eb08a5f1
6 changed files with 114 additions and 28 deletions

View File

@@ -9,6 +9,7 @@ services:
- db - db
- etherpad - etherpad
- back - back
- front
networks: networks:
- app-network - app-network
@@ -24,6 +25,8 @@ services:
- ../doodlestudent/front:/app - ../doodlestudent/front:/app
environment: environment:
- FLASK_ENV=development - FLASK_ENV=development
depends_on:
- back
networks: networks:
- app-network - app-network

View File

@@ -13,7 +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 COPY nginxFront.conf /etc/nginx/conf.d/default.conf
EXPOSE 80 EXPOSE 80

View File

@@ -1,16 +1,29 @@
server { server {
location /api/polls { listen 80;
proxy_pass http://back:8080; server_name _;
proxy_set_header Host $http_host;
root /usr/share/nginx/html;
index index.html;
# Proxy /api and all subpaths to backend service (back container on port 8080)
location /api/ {
proxy_pass http://back:8080/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Connection "";
} }
# Also handle /api without trailing slash
location = /api {
proxy_pass http://back:8080/api;
}
# SPA fallback for client-side routing
location / { location / {
root /usr/share/nginx/html; try_files $uri $uri/ /index.html;
index index.html index.htm;
try_files $uri $uri/ /index.html?$args;
} }
error_page 500 502 503 504 /50x.html; error_page 500 502 503 504 /50x.html;

View File

@@ -1,6 +1,6 @@
FROM nginx:latest FROM nginx:latest
COPY nginx.conf /etc/nginx/conf.d/default.conf COPY nginxFront.conf /etc/nginx/conf.d/default.conf
COPY index.html /usr/share/nginx/html/ COPY index.html /usr/share/nginx/html/

View File

@@ -1,5 +1,28 @@
upstream front{
server front:5000;
}
upstream back{
server back:8080;
}
upstream etherpad{
server etherpad:9001;
}
upstream db{
server db:3306;
}
upstream smtp{
server smtp:25;
}
##########################
## 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,7 +31,7 @@ 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/; 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;
@@ -17,28 +40,55 @@ server {
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection ""; proxy_set_header Connection "";
} }
location /web/ {
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 "";
}
location /pad/ {
proxy_pass http://etherpad:9001/;
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 "";
}
########################## ##########################
# 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;
} }
} }

20
nginxFront.conf Normal file
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;
}
}