linux nginx 443端口访问

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux nginx 443端口访问相关的知识,希望对你有一定的参考价值。

  • 我是在阿里云上配置443端口 首先点击SSL证书这里 再选择已签发证书下载 就会让你选择下载证书的类型 我这里是nginx 就选择nginx版本下载 如果没有就需要购买了 技术分享图片
  1. 下载好后解压完成是这样的文件技术分享图片
  2. 需要把他上传到阿里云的服务器上
    #mkdir /usr/local/nginx/conf/cert #我这里nginx是编译安装
    #cd /usr/local/nginx/conf/cert
    #mv ~/214xxxxxxxxxxxxx.key cert .
    #mv ~/214xxxxxxxxxxxxx.pem cert .
    #cat nginx.conf
    user nginx;
    worker_processes 4;
    error_log /usr/local/nginx/logs/error.log;
    pid conf/nginx.pid;

       events {
            worker_connections  1024;
       }
    
       http {
            include       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  /usr/local/nginx/logs/access.log  main;
    
       sendfile        on;
       #tcp_nopush     on;
    
       #keepalive_timeout  0;
       keepalive_timeout  65;
    
       #gzip  on;
    
       include /usr/local/nginx/conf/conf.d/*.conf;                        #我这里跳转到了另一个文件
        }

    #cat conf.d/xxx.conf
    server {
    listen 80;
    server_name xxxx.com; #域名
    rewrite ^(.*)$ https://${server_name}$1 permanent; #重定向
    }
    server {
    listen 443;
    server_name xxxx.com; #域名
    ssl on;
    ssl_certificate cert/214xxxxxxxxxxxxx.pem; #文件位置
    ssl_certificate_key cert/214xxxxxxxxxxxxx.key; #同上
    ssl_session_timeout 5m;
    ssl_ciphers xxxxx-xxx-xxx128-xxx-xxx256:xxxxx:xxxxx:xxx:xxxx:!NULL:!aNULL:!MD5:!ADH:!RC4; # 秘钥 我这个是从阿里云上获取的
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #协议
    ssl_prefer_server_ciphers on;
    index index.php index.htm index.html;
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

     location ~ .php$ {                                                                    #我这里还有配置php
         root           /opt/www;                                                            #网站位置 
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include        fastcgi_params;
     }
     location / {
        root /opt/www;                                                                       #网站位置
        index index.php index.html index.htm;
        if (!-e  $request_filename) {
        rewrite ^(.*)$ /index.php$1 last;                            
    }

    }
    }

以上是关于linux nginx 443端口访问的主要内容,如果未能解决你的问题,请参考以下文章

Nginx响应80和443端口的访问配置

nginx非80端口配置 外网无法访问

nginx非80端口配置 外网无法访问

[Nginx]-外部多端口映射Https443端口配置

Nginx如何配置多个服务域名解析共用80端口详解

nginx https必须是443吗