Skip to content

Commit

Permalink
feat: add nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
phillychi3 committed Dec 27, 2024
1 parent 8abb52e commit 7cc63e1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 1 addition & 10 deletions frontend/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
})
35 changes: 35 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 7cc63e1

Please sign in to comment.