php C Nginx C Rails中的WordPress博客使用mime类型的文本/ html加载样式和脚本
发布时间:2023-12-12 16:49:25 所属栏目:Nginx 来源:DaWei
导读: 我刚刚在Rails应用程序的一个/博客目录下安装了一个Wordpress博客,它运行在Unicorn和Nginx上,当我访问我的domain.com/blog页面时,我的样式表和脚本在浏览器中没有被正确加载. Chrome控制台给
我刚刚在Rails应用程序的一个/博客目录下安装了一个Wordpress博客,它运行在Unicorn和Nginx上,当我访问我的domain.com/blog页面时,我的样式表和脚本在浏览器中没有被正确加载. Chrome控制台给我以下错误: >资源解释为样式表,但使用MIME类型text / html进行传输 一直在试图解决这个问题,在这里尝试了很多解决方案,但仍然无法通过…似乎需要改变我的Nginx配置,特别是对于博客/ php位置.这是我的配置: upstream unicorn { server unix:/tmp/unicorn.domain.sock fail_timeout=0; } server { server_name www.domain.com; return 301 $scheme://domain.com$request_uri; } server { listen 80 default deferred; server_name domain.com; root /home/dcs/htdocs/domain/current/public; access_log /home/dcs/htdocs/domain/log/access.log; error_log /home/dcs/htdocs/domain/log/error.log; location /blog { try_files $uri $uri/ /blog/index.php?$args; } location ~ .php${ fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME home/dcs/htdocs/domain/$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } try_files $uri/index.html $uri @unicorn; location @unicorn { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://unicorn; } error_page 500 502 503 504 /500.html; keepalive_timeout 10; } 最佳答案 确保您的nginx配置中定义了一个类型指令. Syntax: types { ... } Default: types { text/html html; image/gif gif; image/jpeg jpg; } Context: http,server,location将MIME类型的文件扩展名映射到响应.扩展名不区分大小写.几个扩展可以映射到一个类型,例如: types { text/css css; application/javascript js; application/json json; }资料来源:http://nginx.org/en/docs/http/ngx_http_core_module.html#types (编辑:鲜蔬坊站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Nginx重写的多个条件
- django-如何提供存储在cassandra数据库中的图像?
- 如何阻止访问我的网络服务器上的.svn /条目?
- 使用NGINX auth_request代理设置头文件
- node.js-代理nginx Express-静态文件上的404
- Nginx proxy_ssl_certificate未按预期工作
- php – Nginx – Rails中的WordPress博客使用mime类型的文本
- nginx的http_sub_module/sub_filter和反向代理无法正常工作
- Nginx站点配置模板和变量
- Nginx:什么是X-Forwarded-For WebSockets的替代品?
推荐文章
站长推荐