参考:https://blog.csdn.net/a873217486/article/details/106097855
阿里云域名配置https的参考例子:
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 80;listen 443 ssl;server_name 域名.com www.域名.com;root html;index index.html index.htm;ssl_certificate cert/域名申请的ssl证书的文件.com.pem;ssl_certificate_key cert/域名申请的ssl证书的文件.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;if ($http_user_agent ~* "Go-http-client/1.1" ){ return 403; }# 反向代理新后台接口服务location /apis {rewrite ^/apis/(.*)$ /$1 break;proxy_pass http://127.0.0.1:9001;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}location / {alias /home/wwwroot/default/dist/; #默认访问vue静态文件目录(dist路径)index index.html; #默认访问文件try_files $uri $uri/ /index.html; #目录不存在则执行index.html}}#可选配置,配置http重定向到https#server#{# listen 80;# server_name zilvren.com www.zilvren.com;# rewrite ^(.*)$ https://$host$1 permanent; #将所有http请求通过rewrite重定向到https。# location / {# alias /home/wwwroot/default/dist/; #默认访问vue静态文件目录(dist路径)# index index.html; #默认访问文件# try_files $uri $uri/ /index.html; #目录不存在则执行index.html# }#}}
如果阿里云的域名需要www和https的DNS的话,则这两种方式都需要在阿里云的域名DNS解析器中配置
