一、Nginx的SSL模块安装进入到你的nginx安装目录下面cd /usr/local/nginx输入./configure --prefix/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module输入make操作完成后会出现objs文件夹文件夹里有nginx文件进入objscd /usr/local/nginx/objs输入./nginx -V出现了configure arguments: --with-http_ssl_module 证明已经安装成功二、配置SSL证书进入conf/usr/local/nginx/conf配置nginx.confworker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; server { listen 80; server_name 你的域名; # 当访问HTTP时重定向到HTTPS rewrite ^(.*)$ https://$host$1 permanent; } server { listen 443 ssl; server_name 你的域名; # 确保这里有一个分号 ssl_certificate /usr/local/nginx/conf/cert/你的pem; ssl_certificate_key /usr/local/nginx/conf/cert/你的key; # SSL相关配置可以添加其他SSL指令例如ssl_protocols, ssl_ciphers等 location / { root /home/server/你的dist; index index.html index.htm; try_files $uri $uri/ /index.html; } location /api/ { proxy_pass http://localhost:8088/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } }