Skip to content

Commit

Permalink
feat: add nginx configs and deployment info
Browse files Browse the repository at this point in the history
  • Loading branch information
Lena Ebner committed Dec 13, 2023
1 parent f187aa8 commit dcff001
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,18 @@ A robot that tells jokes to the user. Able to detect the user’s facial express
- https://www.kaggle.com/datasets/ananthu017/emotion-detection-fer
- https://www.kaggle.com/datasets/chazzer/smiling-or-not-face-data
- Three.js https://threejs.org/examples/#webgl_animation_skinning_morph

## Deployment

VM IP: 193.170.119.173

- Frontend https://joke.servegame.com
- Backend http://joke-api.servegame.com

- install https certificat `sudo certbot --nginx --agree-tos --preferred-challenges http -d joke.servegame.com`
- both were started with pm2 and nginx reverse proxy
- `pm2 start recommender.py --interpreter python3 --name "recommender"`
- `pm2 start npm --name "robotui" -- start`
- `pm2 monit`
- `pm2 status`
- `pm2 logs`
36 changes: 36 additions & 0 deletions joke-api.servegame.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
server {
# SSL configuration # default_server
server_name joke-api.servegame.com;
listen 193.170.119.173:443 ssl; # managed by Certbot

location / {
proxy_pass http://localhost:5000;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}

ssl_certificate /etc/letsencrypt/live/joke.servegame.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/joke.servegame.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
if ($host = joke-api.servegame.com) {
return 301 https://$host$request_uri;
} # managed by Certbot


server_name joke-api.servegame.com;
listen 80;
return 404; # managed by Certbot
}
63 changes: 63 additions & 0 deletions joke.servegame.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
server {

server_name joke.servegame.com www.joke.servegame.com;
listen 193.170.119.173:443 ssl; # managed by Certbot

location / {
# Reverse proxy for Next server
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}

# Needed so that downloads are working
location /logs {
alias /var/www/joke/public/logs;
expires 30d;
add_header Cache-Control "public, max-age=2592000";

types {
application/json json;
}

# Reverse proxy for Next server
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}


# listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/joke.servegame.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/joke.servegame.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


server {
if ($host = joke.servegame.com) {
return 301 https://$host$request_uri;
} # managed by Certbot



server_name joke.servegame.com www.joke.servegame.com;
listen 80;
return 404; # managed by Certbot
}

0 comments on commit dcff001

Please sign in to comment.