可以使用listen指令来指定 HTTPS 的端口,然后使用ssl和http2指令来启用 SSL 和 HTTP/2 功能。例如:se...
# nginx.confdaemonoff;pidtmp/nginx.pid;error_logstderrdebug;events{}http{access_logtmp/access.log;default_typetext/html;server{listen443ssl;# SSL 协议版本ssl_protocolsTLSv1.2;# 证书ssl_certificatessl/rsa.pem;# 私钥ssl_certificate_keyssl/rsa.key;# ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:...
{ listen 80; server_name zh.gong.com; root /website/zh; index index.php; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS on; include fastcgi_params; } } # 6、创建进程管理...
listen 80; server_name localhost; return 301 https://localhost$request_uri; charset UTF-8; location / { root html; # 这个是指定一个项目所在目录 index index.html index.htm; # 这个是指定首页的文件名 } } server { listen 80 default backlog=2048; listen 443 ssl; server_name localhost; ssl...
listen 80; # 对于所有请求,代理到后端服务器 location / { proxy_pass http://backend; } } 你可以通过更新upstream配置块,在轮循、最少连接数和IP哈希这些负载均衡方法之间进行切换。 高级掌握:安全性与优化 开启HTTPS: 用Let's Encrypt 来保护你的网站安全 ...
upstream mysvr { server 127.0.0.1:7878; server 192.168.10.121:3333 backup; # 热备 } error_page 404 https://www.baidu.com; # 错误页 server { keepalive_requests 120; # 单连接请求上限次数 listen 4545; # 监听端口 server_name 127.0.0.1; # 监听地址 location ~*^.+$ { # 请求的URL过滤,...
listen 80; server_name ;#这里很重要二级域名配置 rewrite ^(.*)$ https://$host$1 permanent; #用于将http页面重定向到https页面 location / { proxy_pass http://127.0.0.1:9897;#nodejs后端项目地址端口,开启HTTP强制转HTTPS后直接走HTTPS里的 ...
在Nginx 中防止 ssl 证书被其他域名“窜用”(即防止未经授权的域名使用你的 SSL 证书),需要确保你的服务器配置只允许合法域名访问,并通过适当的配置阻止非法域名的 HTTPS 请求。 一般情况下,将多个域名绑定到该服务器(默认页)后,直接通过 http 方式可以正常访问。可以再通过配置,以支持 https 方式访问,但是,配置...
server { listen 80; server_name yourdomain.com; return 301 https://$server_name$request_uri;} 四、测试HTTPS访问 完成上述步骤后,需要对HTTPS访问进行测试,确保一切正常。 在浏览器中输入网站的HTTP地址,观察是否自动重定向到HTTPS地址,并检查浏览器地址栏是否显示绿色的锁形图标,这表明网站已成功启用HTTPS且...
2、开启https加密,目前http2.0只支持开启了https的网站 3、nginx的版本必须在1.9.5以上,原因是nginx从1.9.5开始,已经用 http_v2_module 模块替换了 ngx_http_spdy_module 检查自己的nginx版本和OpenSSL版本(升级openssl版本不必安装新的openssl,稍后详解步骤) ...