欢迎来到代码驿站!

当前位置:首页 >

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

时间:2020-09-06 18:00:18|栏目:|点击:

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; 
 }

上一篇:浅谈Python描述数据结构之KMP篇

栏    目:

下一篇:R语言ggplot2边框背景去除的实现

本文标题:nginx 代理80端口转443端口的实现

本文地址:http://www.codeinn.net/misctech/4605.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有