diff --git a/docker-compose.yml b/docker-compose.yml index 1a025c2..0dc179a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,6 +38,17 @@ services: - lithium-network depends_on: - backend + nginx: + image: nginx:latest + container_name: lithium-nginx + volumes: + - "./nginx.conf:/etc/nginx/conf.d/default.conf" + ports: + - "80:80" + networks: + - lithium-network + depends_on: + - frontend volumes: postgres_data: diff --git a/frontend/web/vite.config.ts b/frontend/web/vite.config.ts index bf852dc..a215d01 100644 --- a/frontend/web/vite.config.ts +++ b/frontend/web/vite.config.ts @@ -3,14 +3,5 @@ import { vite as vidstack } from 'vidstack/plugins' import { defineConfig } from 'vite' export default defineConfig({ - plugins: [vidstack(), sveltekit()], - server: { - proxy: { - '/api': { - target: 'http://localhost:8000', - changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, '') - } - } - } + plugins: [vidstack(), sveltekit()] }) diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..36f7c4d --- /dev/null +++ b/nginx.conf @@ -0,0 +1,35 @@ +upstream frontend { + server frontend:3000; +} + +upstream backend { + server backend:8000; +} + + +limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s; +limit_req_status 429; +limit_conn_status 429; + + +server { + listen 80; + server_name localhost; + client_max_body_size 30m; + + location /api { + proxy_pass http://backend; + rewrite ^/api/(.*) /$1 break; + proxy_set_header Host $host; + limit_req zone=one burst=10 nodelay; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + proxy_pass http://frontend; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} \ No newline at end of file