Nginx 域名映射简明设置

在 /etc/nginx/conf.d 目录下添加配置文件内容如下:

server {
    server_name  zhaobiao.58.com;
    listen 80;
    listen 443 ssl;
    ssl_certificate  /opt/soft/nginx/server.crt;
    ssl_certificate_key  /opt/soft/nginx/server_nopwd.key;
    
    location / {
            
        proxy_pass http://127.0.0.1:9091;
        proxy_redirect         off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }
}

关于 https 的证书生成,可以通过  let's encrypt 免费申请,也可以通过以下命令生成:

openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl rsa -in server.key -out server_nopwd.key
openssl x509 -req -days 365 -in server.csr -signkey server_nopwd.key -out server.crt

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注