Add a self-signed SSL certificate using OpenSSL

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

posted @ 2023-07-18 02:00  LexLuc  阅读(7)  评论(0编辑  收藏  举报