-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from CS3219-AY2425S1/enhancement/api-gateway
Add API gateway
- Loading branch information
Showing
51 changed files
with
425 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
user nginx; | ||
worker_processes auto; | ||
|
||
error_log /var/log/nginx/error.log notice; | ||
pid /var/run/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
|
||
#gzip on; | ||
|
||
map $http_upgrade $connection_upgrade { | ||
default upgrade; | ||
'' close; | ||
} | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} |
2 changes: 2 additions & 0 deletions
2
api-gateway/templates/api_conf.d/admin_conf.d/matching_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
location /admin/matching-service/ { | ||
} |
5 changes: 5 additions & 0 deletions
5
api-gateway/templates/api_conf.d/admin_conf.d/question_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
location /admin/question-service/ { | ||
location /admin/question-service/questions { | ||
proxy_pass http://question-service/questions; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
api-gateway/templates/api_conf.d/api_backends.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
upstream user-service { | ||
server user-service:$USER_SVC_PORT; | ||
} | ||
|
||
upstream question-service { | ||
server question-service:$QUESTION_SVC_PORT; | ||
} | ||
|
||
upstream matching-service { | ||
server matching-service:$MATCHING_SVC_PORT; | ||
} | ||
|
||
upstream collab-service { | ||
server collab-service:$COLLAB_SVC_PORT; | ||
} | ||
|
||
upstream frontend { | ||
server frontend:$FRONTEND_PORT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
location /verify-token { | ||
internal; | ||
|
||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
proxy_pass http://user-service/auth/verify-token; | ||
} | ||
|
||
location /verify-owner { | ||
internal; | ||
|
||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
proxy_pass http://user-service/auth/verify-owner; | ||
} | ||
|
||
location /verify-admin { | ||
internal; | ||
|
||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
proxy_pass http://user-service/auth/verify-admin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
location / { | ||
proxy_pass http://frontend; | ||
} |
2 changes: 2 additions & 0 deletions
2
api-gateway/templates/api_conf.d/owner_conf.d/matching_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
location /owner/matching-service/ { | ||
} |
2 changes: 2 additions & 0 deletions
2
api-gateway/templates/api_conf.d/owner_conf.d/question_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
location /owner/question-service/ { | ||
} |
10 changes: 10 additions & 0 deletions
10
api-gateway/templates/api_conf.d/private_conf.d/collab_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
location /private/collab-service/ { | ||
proxy_pass http://collab-service/; | ||
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; | ||
} |
5 changes: 5 additions & 0 deletions
5
api-gateway/templates/api_conf.d/private_conf.d/matching_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
location /private/matching-service/ { | ||
location /private/matching-service/match { | ||
proxy_pass http://matching-service/match; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
api-gateway/templates/api_conf.d/private_conf.d/question_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
location /private/question-service/ { | ||
} |
2 changes: 2 additions & 0 deletions
2
api-gateway/templates/api_conf.d/private_conf.d/user_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
location /private/user-service/ { | ||
} |
23 changes: 23 additions & 0 deletions
23
api-gateway/templates/api_conf.d/public_conf.d/collab_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
location /public/collab-service/ { | ||
location /public/collab-service/chat { | ||
proxy_pass http://collab-service/chat; | ||
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; | ||
} | ||
|
||
location /public/collab-service/yjs { | ||
proxy_pass http://collab-service/yjs; | ||
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; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
api-gateway/templates/api_conf.d/public_conf.d/matching_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
location /public/matching-service/ { | ||
location /public/matching-service/match/ { | ||
location /public/matching-service/match/subscribe/ { | ||
proxy_pass http://matching-service/match/subscribe/; | ||
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; | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
api-gateway/templates/api_conf.d/public_conf.d/question_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
location /public/question-service/ { | ||
location /public/question-service/questions { | ||
limit_except GET { | ||
deny all; | ||
} | ||
proxy_pass http://question-service/questions; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
api-gateway/templates/api_conf.d/public_conf.d/user_service.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
location /public/user-service/ { | ||
location /public/user-service/auth { | ||
proxy_pass http://user-service/auth; | ||
} | ||
|
||
location /public/user-service/users { | ||
proxy_pass http://user-service/users; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
include conf.d/api_conf.d/api_backends.conf; | ||
|
||
server { | ||
listen $PORT; | ||
listen [::]:$PORT; | ||
|
||
location /public/ { | ||
include conf.d/api_conf.d/public_conf.d/*.conf; | ||
} | ||
|
||
location /private/ { | ||
auth_request /verify-token; | ||
include conf.d/api_conf.d/private_conf.d/*.conf; | ||
} | ||
|
||
location /owner/ { | ||
auth_request /verify-owner; | ||
include conf.d/api_conf.d/owner_conf.d/*.conf; | ||
} | ||
|
||
location /admin/ { | ||
auth_request /verify-admin; | ||
include conf.d/api_conf.d/admin_conf.d/*.conf; | ||
} | ||
|
||
include conf.d/api_conf.d/auth.conf; | ||
|
||
include conf.d/api_conf.d/frontend.conf; | ||
} | ||
|
||
include conf.d/map_conf.d/*.conf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.