Re: [openresty] 春哥,站点http可以正常显示,但是用https无法正常显示,请问是不是我nginx.conf配置错误了?

74 views
Skip to first unread message
Message has been deleted

Kwanhur Huang

unread,
May 11, 2018, 6:03:55 AM5/11/18
to openresty, Kwanhur Huang
hello,

因为http块里设置default_type 为octet-stream,所以被下载是正确的。

可以考虑在server块里设置 default_type text/plain;


Kwanhur Huang
TL;DR

在 2018年5月11日,下午5:33,Hggv kiwier <thek...@gmail.com> 写道:

我站点http://www.oneacreland.com 是显示正常的,但是用  https://www.oneacreland.com  ,首页被自动下载了,怎么会出现这种情况?

生产环境:centos7 ,openresty,php7.用了cloudflare的cdn
ssl证书是申请的腾讯云的,路径地址放在了/usr/local/openresty/nginx/conf 下面

请问我是不是哪里做错了?



# openresty -t
nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful  


给出自己的nginx.conf的配置:



user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;
    
    client_max_body_size 8m;    #允许客户端请求的最大单文件字节数
    client_body_buffer_size 2m;  #缓冲区代理缓冲用户端请求的最大字节

   #WAF
    lua_shared_dict limit 50m;  #防cc使用字典,大小50M
    lua_shared_dict guard_dict 100m;
    lua_shared_dict dict_captcha 70m;
    lua_max_running_timers 1;
    lua_package_path "/usr/local/openresty/nginx/conf/waf/?.lua";
    init_by_lua_file "/usr/local/openresty/nginx/conf/waf/init.lua";
    access_by_lua_file "/usr/local/openresty/nginx/conf/waf/access.lua";
   

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       80;
        listen       [::]:80 default_server;
        server_name  104.131.43.152;
        
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root    html;
            
            index  index.html index.htm index.php;
        }


        location /phpmyadmin {
            alias /usr/share/phpMyAdmin;
            index index.php;
         }

       location ~ /phpmyadmin/.+\.php$ {
            if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
             set $valid_fastcgi_script_name $1;
            }
             include fastcgi_params;
             fastcgi_pass 127.0.0.1:9000;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
         }

       

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # 这里新加的
        # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置.
        # Fastcgi服务器和程序(PHP,Python)沟通的协议.
        location ~ \.php$ {
            # 设置监听端口
            fastcgi_pass   127.0.0.1:9000;
            # 设置nginx的默认首页文件(上面已经设置过了,可以删除)
            fastcgi_index  index.php;
            # 设置脚本文件请求的路径
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            # 引入fastcgi的配置文件
            include        fastcgi_params;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /document_root$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    
    server {
        listen  443 ssl;
        server_name  www.oneacreland.com;
        ssl on;
        include       mime.types;
       ssl_certificate       1_www.oneacreland.com_bundle.crt;
       ssl_certificate_key   2_www.oneacreland.com.key;
       

       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;
       ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

       ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
       ssl_prefer_server_ciphers  on;

       location / {
            root   html;
           index  index.html index.htm index.php;
        }
   }

}



给出自己cloudflare的配置截图:






--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
<屏幕快照 2018-05-08 下午11.27.40.png><屏幕快照 2018-05-08 下午11.27.48.png><屏幕快照 2018-05-08 下午11.28.02.png>

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages