作者:泡乙唐 | 来源:互联网 | 2023-06-16 12:30
server{#listen443ssl;listen443;sslon;#配置HTTPS的默认访问端口为443。#如果未在此处配置HTTPS的默认访问端口,可能会造
server {# listen 443 ssl;listen 443;ssl on;#配置HTTPS的默认访问端口为443。#如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。#如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。server_name xxx.com; #需要将yourdomain.com替换成证书绑定的域名。#root html;#index index.html index.htm;ssl_certificate cert/cert-file-name.pem; #需要将cert-file-name.pem替换成已上传的证书文件的名称。ssl_certificate_key cert/cert-file-name.key; #需要将cert-file-name.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; #表示使用的TLS协议的类型。ssl_prefer_server_ciphers on;#location / {# root html; #站点目录。# index index.html index.htm;#}#listen 80;#server_name xxx.com;# 静态文件访问路径location ^~ /static { # 注意:location 后面的路径名与最后一级目录名一致# root /home/mayanan/docker_test03/; # 文件目录所在的地址# alias /home/mayanan/docker_test03/static;alias /home/mayanan/flask_nginx_docker_gunicorn/static;autoindex on; # 目录显示所有文件}location / {proxy_pass http://127.0.0.1:4000;}# 支持websocket的配置项location ^~ /ws {proxy_pass http://127.0.0.1:4000;# WebScoket Supportproxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}}# http请求默认转换为https的配置项
server {listen 80;server_name xxx.com; #需要将yourdomain.com替换成证书绑定的域名。rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS。location / {proxy_pass http://127.0.0.1:4000;}
}