File tree Expand file tree Collapse file tree 8 files changed +71
-16
lines changed
templates/api_conf.d/public_conf.d Expand file tree Collapse file tree 8 files changed +71
-16
lines changed Original file line number Diff line number Diff line change
1
+ user nginx;
2
+ worker_processes auto;
3
+
4
+ error_log /var/log/nginx/error.log notice;
5
+ pid /var/run/nginx.pid ;
6
+
7
+
8
+ events {
9
+ worker_connections 1024 ;
10
+ }
11
+
12
+
13
+ http {
14
+ include /etc/nginx/mime.types ;
15
+ default_type application/octet-stream ;
16
+
17
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
18
+ '$status $body_bytes_sent "$http_referer" '
19
+ '"$http_user_agent" "$http_x_forwarded_for"' ;
20
+
21
+ access_log /var/log/nginx/access.log main;
22
+
23
+ sendfile on;
24
+ #tcp_nopush on;
25
+
26
+ keepalive_timeout 65 ;
27
+
28
+ #gzip on;
29
+
30
+ map $http_upgrade $connection_upgrade {
31
+ default upgrade;
32
+ '' close;
33
+ }
34
+
35
+ include /etc/nginx/conf.d/*.conf;
36
+ }
Original file line number Diff line number Diff line change 1
1
location /public/matching-service/ {
2
+ location /public/matching-service/match/ {
3
+ location /public/matching-service/match/subscribe/ {
4
+ proxy_pass http://matching-service/match/subscribe/;
5
+ proxy_http_version 1.1;
6
+ proxy_set_header Upgrade $http_upgrade;
7
+ proxy_set_header Connection $connection_upgrade;
8
+ proxy_set_header Host $host;
9
+ proxy_set_header X-Real-IP $remote_addr;
10
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
11
+ proxy_set_header X-Forwarded-Proto $scheme;
12
+ }
13
+ }
2
14
}
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ services:
40
40
image : nginx:1.26
41
41
volumes :
42
42
- ./api-gateway/templates:/etc/nginx/templates
43
+ - ./api-gateway/nginx.conf:/etc/nginx/nginx.conf
43
44
ports :
44
45
- $API_GATEWAY_PORT:$API_GATEWAY_PORT
45
46
environment :
Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ import { SearchProgress } from "@/components/matching/search-progress";
5
5
import { SelectionSummary } from "@/components/matching/selection-summary" ;
6
6
import { useToast } from "@/components/hooks/use-toast" ;
7
7
import { useAuth } from "@/app/auth/auth-context" ;
8
- import { joinMatchQueue } from "@/lib/join-match-queue" ;
9
- import { leaveMatchQueue } from "@/lib/leave-match-queue" ;
10
- import { subscribeMatch } from "@/lib/subscribe-match" ;
8
+ import { joinMatchQueue } from "@/lib/api/matching-service/ join-match-queue" ;
9
+ import { leaveMatchQueue } from "@/lib/api/matching-service/ leave-match-queue" ;
10
+ import { subscribeMatch } from "@/lib/api/matching-service/ subscribe-match" ;
11
11
12
12
export default function FindMatch ( ) {
13
13
const [ selectedDifficulty , setSelectedDifficulty ] = useState < string > ( "" ) ;
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ const constructUri = (
13
13
`http://${ process . env . NEXT_PUBLIC_BASE_URI || baseUri } :${ process . env . NEXT_PUBLIC_API_GATEWAY_PORT } /${ authType } /${ serviceName } ` ;
14
14
15
15
export const userServiceUri : ( baseUri : string , authType : AuthType ) => string = (
16
- baseUri ,
17
- authType
16
+ baseUri : string ,
17
+ authType : AuthType
18
18
) => constructUri ( baseUri , authType , "user-service" ) ;
19
19
export const questionServiceUri : (
20
20
baseUri : string ,
@@ -27,9 +27,15 @@ export const matchingServiceUri: (
27
27
) => string = ( baseUri , authType ) =>
28
28
constructUri ( baseUri , authType , "matching-service" ) ;
29
29
30
- const constructWebSockUri = ( baseUri : string ) =>
31
- `ws://${ process . env . NEXT_PUBLIC_BASE_URI || baseUri } :${ process . env . NEXT_PUBLIC_API_GATEWAY_PORT } ` ;
30
+ const constructWebSockUri = (
31
+ baseUri : string ,
32
+ authType : AuthType ,
33
+ serviceName : string
34
+ ) =>
35
+ `ws://${ process . env . NEXT_PUBLIC_BASE_URI || baseUri } :${ process . env . NEXT_PUBLIC_API_GATEWAY_PORT } /${ authType } /${ serviceName } ` ;
32
36
33
- export const matchingServiceWebSockUri : ( baseUri : string ) => string = (
34
- baseUri
35
- ) => constructWebSockUri ( baseUri ) ;
37
+ export const matchingServiceWebSockUri : (
38
+ baseUri : string ,
39
+ authType : AuthType
40
+ ) => string = ( baseUri , authType ) =>
41
+ constructWebSockUri ( baseUri , authType , "matching-service" ) ;
Original file line number Diff line number Diff line change 1
- import { matchingServiceUri } from "@/lib/api/api-uri" ;
1
+ import { AuthType , matchingServiceUri } from "@/lib/api/api-uri" ;
2
2
3
3
export const joinMatchQueue = async (
4
4
jwtToken : string ,
@@ -11,7 +11,7 @@ export const joinMatchQueue = async (
11
11
difficulty : complexity ,
12
12
} ) . toString ( ) ;
13
13
const response = await fetch (
14
- `${ matchingServiceUri ( window . location . hostname ) } /match/queue/${ userId } ?${ params } ` ,
14
+ `${ matchingServiceUri ( window . location . hostname , AuthType . Private ) } /match/queue/${ userId } ?${ params } ` ,
15
15
{
16
16
method : "POST" ,
17
17
headers : {
Original file line number Diff line number Diff line change 1
- import { matchingServiceUri } from "@/lib/api/api-uri" ;
1
+ import { AuthType , matchingServiceUri } from "@/lib/api/api-uri" ;
2
2
3
3
export const leaveMatchQueue = async (
4
4
jwtToken : string ,
@@ -11,7 +11,7 @@ export const leaveMatchQueue = async (
11
11
difficulty : complexity ,
12
12
} ) . toString ( ) ;
13
13
const response = await fetch (
14
- `${ matchingServiceUri ( window . location . hostname ) } /match/queue/${ userId } ?${ params } ` ,
14
+ `${ matchingServiceUri ( window . location . hostname , AuthType . Private ) } /match/queue/${ userId } ?${ params } ` ,
15
15
{
16
16
method : "DELETE" ,
17
17
headers : {
Original file line number Diff line number Diff line change 1
- import { matchingServiceWebSockUri } from "@/lib/api/api-uri" ;
1
+ import { AuthType , matchingServiceWebSockUri } from "@/lib/api/api-uri" ;
2
2
3
3
export const subscribeMatch = async (
4
4
userId : string ,
@@ -10,6 +10,6 @@ export const subscribeMatch = async (
10
10
difficulty : complexity ,
11
11
} ) ;
12
12
return new WebSocket (
13
- `${ matchingServiceWebSockUri ( window . location . hostname ) } /match/subscribe/${ userId } ?${ params } `
13
+ `${ matchingServiceWebSockUri ( window . location . hostname , AuthType . Public ) } /match/subscribe/${ userId } ?${ params } `
14
14
) ;
15
15
} ;
You can’t perform that action at this time.
0 commit comments