sudo apt-get install openssl
cd /etc/nginx
sudo mkdir ssl
sudo openssl req -batch -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout /etc/nginx/ssl/server.key \
-out /etc/nginx/ssl/server.crt
cd /etc/nginx/sites-enabled/
sudo vim fastapi_nginx
server {
listen 80;
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
server_name <domain-name OR ip-address>;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
sudo nginx -t
sudo service nginx restart