Linux os Nginx 配置https 自定义端口非443端口

阿里云安全组添加端口2020

在这里插入图片描述

服务器开启2020端口

iptables 开放2020端口

-A INPUT -m state--state NEW -m tcp -p tcp --dport 2020 -j ACCEPT

重启iptables

service iptables restart 

我这里使用的是内置防火墙

开放2020

firewall-cmd --zone=public --add-port=2020/tcp --permanent

重启防火墙

systemctl restart firewalld
下面是我的2020端口https nginx配置全部代码

正常配置可以从::/etc/nginx/nginx.conf

下面是我的配置路径
路径:/etc/nginx/conf.d/admin.conf

server {
  #listen 	80; 
  listen 	2020 ssl;
  server_name www.我的网址.com;

  client_max_body_size 10M;
  ssl on;
  ssl_session_cache	shared:SSL:10m;
  ssl_session_timeout 10s;
  ssl_certificate /etc/nginx/conf.d/ssl/adminSSl.pem;
  ssl_certificate_key /etc/nginx/conf.d/ssl/adminSSl.key;
 # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 # ssl_ciphers  HIGH:!aNULL:!MD5;
 # error_page 497 301 https://$http_host$request_uri;

  access_log /logs/admin.log;
  index index.html;
  root /html/peixun/dist;
  charset utf-8;
  location / {
    try_files $uri $uri/ @router;
           
    index index.html index.htm;
  }
  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 16k;
  gzip_comp_level 9;
  gzip_types text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
  gzip_vary off;
  gzip_disable "MSIE [1-6]\.";
  error_page   405 =200 @405;

   location @405{
       root  /opt/htdocs;
   } 
	


  location @router {
    rewrite ^.*$ /index.html last;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log on;
  }
}

重启nginx

service nginx restart

去端口 增加

server {
    listen       80;
    server_name  vx.tianyuanzhuyi.cn;
    rewrite ^(.*) https://$host$1 permanent;
}

此时便可访问:
https://www.我的网址.com:2020 访问到网站了

如未能成功,请下方留言,留下你的联系方式。

  • 12
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

托马斯的冰淇淋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值