阿里云SSL证书 ![image-20221104214018315](https://wangyuedong-img.oss-cn-beijing.aliyuncs.com/img/image-20221104214018315.png) 配置nginx ```bash #user nobody; worker_processes 1; error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # http配置 server { listen 80; server_name www.xiaoyaodijun.com; location / { root /var/app/dist/; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } #https 配置 server { listen 443 ssl; server_name web.xiaoyaodijun.com; root /var/app2/dist; #文件地址 index index.html index.htm; #默认首页 ssl_certificate /var/cret/web.xiaoyaodijun.pem; #证书地址 ssl_certificate_key /var/cret/web.xiaoyaodijun.key; #证书地址 ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; #代理请求http接口 location /ospapi/{ proxy_pass http://xxx.xxx.xx.xx:xxxx/front/; } } #http请求自动重订向https     server{         listen 80;         server_name web.xiaoyaodijun.com;         rewrite ^/(.*)$ https://web.xiaoyaodijun.com:443/$1 permanent;     } } ``` ```bash # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user wangyuedong; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { 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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80; listen [::]:80; server_name _; root /var/www/html; index index.html index.htm; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location = / { } error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } # Settings for a TLS enabled server. server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name _; root /var/www/html; index index.html index.htm; ssl_certificate "/var/www/ssl/7764255_wangyuedong.com.pem"; ssl_certificate_key "/var/www/ssl/7764255_wangyuedong.com.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location = / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } #reload server{ listen 80; server_name _; rewrite ^/(.*)$ https://wangyuedong.com:443/$1 permanent; } } ```