-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.dev.conf
65 lines (56 loc) · 1.89 KB
/
nginx.dev.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
events {
worker_connections 1024;
}
http {
upstream frontend {
server frontend:3000;
}
upstream api {
server api:8080;
}
# Add MIME types for frontend assets
include /etc/nginx/mime.types;
default_type application/octet-stream;
# WebSocket support for frontend dev server
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name localhost;
# Static files like favicon
location = /favicon.ico {
proxy_pass http://frontend/favicon.ico;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
access_log off;
expires 30d;
add_header Cache-Control "public, no-transform";
}
# Frontend
location / {
proxy_pass http://frontend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
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;
}
# API endpoints
location /api/ {
proxy_pass http://api/;
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;
# CORS headers for development
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET' always;
add_header 'Access-Control-Allow-Headers' 'Content-Type' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
}
}