nginx : set up http/https conf for your server(Ghost)

Let me use cluster.errong.win as a example.
All you need to do is replace the server name and port.
All reqest to cluster.errong.win will be proxyed by http://127.0.0.1:6666

http conf

server {
    listen 80;
    listen [::]:80;

    server_name cluster.errong.win;
    root /home/errong_leng/www/cluster/system/nginx-root;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:6666;
        
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

enable http server to nginx

ln -sf /home/errong_leng/www/cluster/system/files/cluster.errong.win.conf /etc/nginx/sites-available/cluster.errong.win.conf
ln -sf /etc/nginx/sites-available/cluster.errong.win.conf
/etc/nginx/sites-enabled/cluster.errong.win.conf

Use Let's Encrypt

Let's Encrypt is a free, automated, and open Certificate Authority.
/etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --domain cluster.errong.win --webroot /home/errong_leng/www/cluster/system/nginx-root --reloadcmd "nginx -s reload" --accountemail errong.leng@gmail.com

https conf

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name cluster.errong.win;
    root /home/errong_leng/www/cluster/system/nginx-root;

    ssl_certificate /etc/letsencrypt/cluster.errong.win/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/cluster.errong.win/cluster.errong.win.key;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:6666;
        
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

enable https server to nginx

ln -sf /home/errong_leng/www/cluster/system/files/cluster.errong.win-ssl.conf /etc/nginx/sites-available/cluster.errong.win-ssl.conf
ln -sf /etc/nginx/sites-available/cluster.errong.win-ssl.conf
/etc/nginx/sites-enabled/cluster.errong.win-ssl.conf

restart nginx service

service nginx restart

No comments:

Post a Comment

fixed: embedded-redis: Unable to run on macOS Sonoma

Issue you might see below error while trying to run embedded-redis for your testing on your macOS after you upgrade to Sonoma. java.la...