php - Nginx + Yii 应用程序 = js,css - net::ERR_CONNECTION_REFUSED

标签 php css .htaccess nginx yii

我遇到了求救信号。 我在新服务器上从 apache 迁移到 nginx,设置了 nginx+php-fpm+mariadb。

现在除了 MVC 结构的错误之外,还有另一个错误 - Chrome 控制台充满红色 - net::ERR_CONNECTION_REFUSED 在连接到 jpg 和 css 文件时。

它可以是什么?它是 Assets Yii 组件中的错误还是在 NGINX 配置中? 这是我的配置。

server {
    listen 80; 
    server_name    example.ru; 
    root  /var/www/sites/example.ru; 

    set $yii_bootstrap "index.php";

    charset utf-8;

    location / {
        index  index.html $yii_bootstrap;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
        try_files $uri $uri/ /$yii_bootstrap?$args;
    }

    location ~ ^/(protected|framework|themes/\w+/views) {
       deny  all;
    }

    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
       try_files $uri =404;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        fastcgi_pass php-fpm;
                fastcgi_split_path_info  ^(.+\.php)(.*)$;
                set $fsn /$yii_bootstrap;
                if (-f $document_root$fastcgi_script_name){
                    set $fsn $fastcgi_script_name;
                }

                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;


                fastcgi_param  PATH_INFO        $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
    }

    location ~ \.css {
        add_header  Content-Type    text/css;
    }

    location ~ \.js {
        add_header  Content-Type    application/x-javascript;
    }

.htaccess 几乎是空白

AddDefaultCharset UTF-8

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

最佳答案

我在迁移到新服务器后忘记在我的 NGINX 服务器上启用 SSL,并且搜索的所有脚本服务器都以“https://”开头。

关于php - Nginx + Yii 应用程序 = js,css - net::ERR_CONNECTION_REFUSED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47902715/

相关文章:

PHP:从数组中选择 child

html - 如果使用 Bootstrap 选择了某些选项,则隐藏/显示内容

css - 响应列中的嵌入视频在 WebKit 中消失

wordpress - 将 example.com/uplaod/*/*/*.zip 重定向到 example.com/down.php?file=*.zip

.htaccess - Htaccess 和 SEO 友好的固定链接

php - 将用户制作的 SVG (raphael.js) 发送到服务器 (php),以便通过电子邮件发送

php - 图像未显示在队列中的邮件中 - laravel

javascript - 用于替换嵌套结构中匹配括号的正则表达式

jquery - 网站无法在 Safari 浏览器中正确加载

.htaccess - PHP 动态 URL 参数和 GET