用于php cms Kirby的nginx HTTPS配置

时间:2017-05-30 16:47:46

标签: php nginx https content-management-system kirby

我的网站上有关于我的nginx配置的问题。当我使用端口80运行配置时,我没有问题,但是当我使用我的ssl配置将所有内容移动到端口443时,该站点不再响应。我已经尝试了很多,并且没有看到我在这里做错了什么。

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {
        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        include /etc/nginx/conf.d/*.conf;
        #include /etc/nginx/sites-enabled/*;

        server {
                listen 80;

                server_name landing.kayzr.com;
                return 301 https://landing.kayzr.com;
        }

        server {
                listen 443;
                server_name landing.kayzr.com;

                ssl on;
                ssl_certificate /etc/ssl/ssl-bundle.crt;
                ssl_certificate_key /etc/ssl/server.key;
                ssl_session_cache shared:SSL:10m;
                ssl_session_timeout 10m;
                ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DES-CBC3-SHA:!ADH:!AECDH:!MD5;
                ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                ssl_prefer_server_ciphers on;
                ssl_session_cache shared:SSL:10m;
                add_header Strict-Transport-Security "max-age=63072000";
                add_header X-Frame-Options DENY;
                add_header X-Content-Type-Options nosniff;
                ssl_stapling on;
                ssl_stapling_verify on;
                resolver 8.8.8.8 8.8.4.4;

                root /var/www/html;

                index index.php index.html index.htm;

                location ~ \.php$ {
                        include snippets/fastcgi-php.conf;
                        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                }

                rewrite ^/(content|site|kirby)$ /error last;

                rewrite ^/content/(.*).(txt|md|mdown)$ /error last;

                rewrite ^/(site|kirby)/(.*)$ /error last;

                if (!-d $request_filename) {
                        rewrite ^/(.+)/$ /$1 permanent;
                }

                location ~ /panel {
                        try_files $uri $uri/ /panel/index.php?$uri&$args;
                }

                location ~ / {
                        try_files $uri $uri/ /index.php?$uri&$args;
                }

                location ~ (?:^|/)\. {
                        deny all;
                }

                location ~ (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
                        deny all;
                }
        }
}

奇怪的是,当我复制来自&root; / var / www / html'到我的端口80服务器一切都适用于非https。

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:0)

好的我应该在stackoverflow上发布更多内容,每次发布时(我只在几小时后才这样做)解决方案突然出现了。

该文件完全正确。我的安全组在Azure上只打开了443端口。