-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnginx.conf
More file actions
83 lines (68 loc) · 2.76 KB
/
nginx.conf
File metadata and controls
83 lines (68 loc) · 2.76 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
events {}
http {
# Rate Limiting (5 requests per second per IP)
limit_req_zone $binary_remote_addr zone=api:10m rate=5r/s;
upstream user_service {
server user-service:3000;
}
upstream notification_service {
server notification-service:3000;
}
upstream order_service {
server order-service:5000;
}
upstream payment_service {
server payment-service:5000;
}
server {
listen 5000;
server_name localhost;
# User Service
location /api/user/ {
rewrite ^/api/user/(.*)$ /user/$1 break;
proxy_pass http://user_service/;
limit_req zone=api burst=10;
# CORS headers
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Credentials "true" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
}
# Notification Service
location /api/notify/ {
rewrite ^/api/notify/(.*)$ /notify/$1 break;
proxy_pass http://notification_service/;
error_page 401 = /unauthorized;
# CORS headers
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Credentials "true" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
}
# Order Service
location /api/orders/ {
rewrite ^/api/orders/(.*)$ /orders/$1 break;
proxy_pass http://order_service/;
limit_req zone=api burst=10;
# CORS headers
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Credentials "true" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
}
# Payment Service
location /api/payments/ {
rewrite ^/api/payments/(.*)$ /orders/$1 break;
proxy_pass http://payment__service/;
limit_req zone=api burst=10;
# CORS headers
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Credentials "true" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
}
location = /unauthorized {
return 401;
}
}
}