社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  NGINX

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

托马斯的冰淇淋 • 4 年前 • 302 次点击  

阿里云安全组添加端口2020

在这里插入图片描述

服务器开启2020端口

iptables 开放2020端口

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

重启iptables

service iptables restart 
  • 1

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

开放2020

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

重启防火墙

systemctl restart firewalld
  • 1

下面是我的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;
  }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

重启nginx

service nginx restart
  • 1

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

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/53081
 
302 次点击