温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nginx 代理80端口转443端口的实现

发布时间:2020-10-24 09:06:46 来源:脚本之家 阅读:198 作者:诗水人间 栏目:开发技术

nginx.conf配置文件如下

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid    /var/run/nginx.pid;


events {
  worker_connections 1024;
}


http {
  include    /etc/nginx/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 /var/log/nginx/access.log main;

  sendfile    on;
  #tcp_nopush   on;

  keepalive_timeout 65;

  #gzip on;

  include /etc/nginx/conf.d/*.conf;
 
 # 以下属性中以ssl开头的属性代表与证书配置有关,其他属性请根据自己的需要进行配置。
 server {
 listen 443 ssl;  #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
 server_name localhost; #将localhost修改为您证书绑定的域名,例如:www.example.com。
 root html;
 index index.html index.htm;
 ssl_certificate /etc/nginx/huashengshu.top.pem;  #替换成您证书的文件名。
 ssl_certificate_key /etc/nginx/huashengshu.top.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;  
 location / {
  root /etc/nginx/hss;  #站点目录。
  index index.html index.htm;  
 }
 }
 

 server {
 listen 80;
 server_name huashengshu.top;
 rewrite ^(.*)$ https://${server_name}$1 permanent; 
 }

}

起作用的是

 server {
 listen 80;
 server_name huashengshu.top;
 rewrite ^(.*)$ https://${server_name}$1 permanent; 
 }

到此这篇关于nginx 代理80端口转443端口的实现的文章就介绍到这了,更多相关nginx 代理80转443内容请搜索亿速云以前的文章或继续浏览下面的相关文章希望大家以后多多支持亿速云!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI