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

阿里云安全组添加端口2020

Linux os Nginx 配置https 自定义端口非443端口_第1张图片

服务器开启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

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

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

你可能感兴趣的:(nginx)