mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: setup proxy and x-forwarded-for header
This commit is contained in:
1 parent
14b2c1b0d5
commit
1d2ad733ed
3 files changed
+5
No files matched your search
@@ -9,11 +9,13 @@ export default defineConfig({
|
|||||||
'/api': {
|
'/api': {
|
||||||
target: process.env.API_TARGET || 'http://localhost:3000',
|
target: process.env.API_TARGET || 'http://localhost:3000',
|
||||||
changeOrigin: false,
|
changeOrigin: false,
|
||||||
|
xfwd: true,
|
||||||
},
|
},
|
||||||
'/socket.io': {
|
'/socket.io': {
|
||||||
target: process.env.API_TARGET || 'ws://localhost:3000',
|
target: process.env.API_TARGET || 'ws://localhost:3000',
|
||||||
changeOrigin: false,
|
changeOrigin: false,
|
||||||
ws: true,
|
ws: true,
|
||||||
|
xfwd: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ server {
|
|||||||
|
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://backend:3000;
|
proxy_pass http://backend:3000;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api-docs/ {
|
location /api-docs/ {
|
||||||
@@ -18,6 +19,7 @@ server {
|
|||||||
location /socket.io/ {
|
location /socket.io/ {
|
||||||
proxy_pass http://backend:3000;
|
proxy_pass http://backend:3000;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ async function main() {
|
|||||||
const app = express()
|
const app = express()
|
||||||
const server = http.createServer(app)
|
const server = http.createServer(app)
|
||||||
socketServer(server)
|
socketServer(server)
|
||||||
|
app.set('trust proxy', true)
|
||||||
app.use(errorHandler)
|
app.use(errorHandler)
|
||||||
app.use(globalRateLimit)
|
app.use(globalRateLimit)
|
||||||
app.use(sessionMiddleware)
|
app.use(sessionMiddleware)
|
||||||
|
|||||||
Reference in new issue
Block a user