diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-01-18 10:28:53 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-01-18 10:28:53 +0100 |
commit | aa6c4333589c82decf31fdda3ec93237d8b6973e (patch) | |
tree | 16951192b687df1defaa8b518b6014f5ce33dade | |
parent | 24f2680f2f97fb8e3d3eff829d1a41416bdd6562 (diff) |
Update README file
-rw-r--r-- | README.md | 67 |
1 files changed, 63 insertions, 4 deletions
@@ -23,12 +23,11 @@ Now, you can proceed to set up some environment variables: - `JWT_SECRET`: the base64 version of the secret used for JWT tokens. - `EXPO_ACCESS_TOKEN`: the base64 version of the [Expo](https://expo.dev) access token. - `UNREALSPEECH_TOKEN`: [Unrealspeech](https://unrealspeech.com/) access token. -- `RUST_LOG`: level of Rust logging. +- `RUST_LOG`: level of Rust logging (info, debug, ...). - `VITE_API_URL`: url for the backend API. Meanwhile the followings are setted up by default. -- `AUDIO_PATH`: "./assets" - `ALLOWED_HOST`: "0.0.0.0:8000" First of all you must create a new cluster for KinD. We need it for some worker @@ -53,8 +52,10 @@ After that, you'll be able to see what the external IP for the load balancer is. ``` $ k get svc -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -cas-service LoadBalancer 10.96.25.163 172.18.0.3 80:30358/TCP 11m +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +cas-backend-service LoadBalancer 10.96.107.232 172.18.0.3 80:32697/TCP 18h +cas-frontend-service ClusterIP 10.96.49.130 <none> 80/TCP 18h +postgres-service ClusterIP 10.96.150.101 <none> 5432/TCP 18h ``` For the IP above you can test if it works by a HTTP request. @@ -75,3 +76,61 @@ $ curl -X POST http://172.18.0.3/graphql \ If you receive a network error you just need to wait until the `cloud-provider-kind` works. + +## Use Nginx as reverse proxy + +We tested this project in production using Nginx as revere proxy. Indeed, at the +endpoint `server_name` an user could access to the frontend project (i.e. admin +cp). + +First of all, you need to port-forward the `cas-frontend-service` service. + +``` +$ kubectl port-forward svc/cas-frontend-service 8080:80 & +``` + +After that you have to configure Nginx server. + +``` +server { + listen 80; + server_name my-cas4-domain.com; + + location / { + proxy_pass http://0.0.0.0:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /api/graphql { + proxy_pass http://172.18.0.3:80/graphql; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /api { + proxy_pass http://172.18.0.3:80; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} +``` + +After a Nginx restart, just check if the API still works. + +``` +$ curl -X POST http://my-cas4-domain.com/api/graphql \ +-H "Content-Type: application/json" \ +-d '{ + "query": "mutation Login($input: LoginCredentials!) { login(input: $input) { accessToken tokenType userId } }", + "variables": { + "input": { + "email": "info@cas-4.github", + "password": "mysuperpassword" + } + } +}' +``` |