AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 691225
Accepted
Astaar
Astaar
Asked: 2015-05-12 11:06:23 +0800 CST2015-05-12 11:06:23 +0800 CST 2015-05-12 11:06:23 +0800 CST

Windows 上的 nginx 总是返回 text/plain

  • 772

我在 Windows(开发机器)上使用 nginx 1.6.2,我有一个问题,它总是会为任何文件的标题返回一个text/plain值。Content-Type这是一个问题,因为浏览器不会渲染 CSS、计算 JS 等。

默认情况下,我没有默认的 nginx.config 文件(与 Linux 不同),所以我必须从头开始构建它,同时保持它的最小化。通常我的问题是通过包含来解决的,etc/nginx/mime.types所以我从我拥有的 CentOS 服务器复制/粘贴了该文件。但它似乎没有任何效果。我试图故意使包含路径错误,这引发了错误,所以我认为当我使它正确时它实际上被正确解析了。

所以我完全不知道为什么 nginx 会为我的每一笔罚款都返回 text/plain。

这是我的 nginx.conf 文件:

events {
  worker_connections  1024;
}

http {
    include     D:/dev/nginx/mime.types;

    expires off;

    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  D:/dev/nginx/logs/access.log  main;
    error_log  D:/dev/nginx/logs/error.log;


    upstream backend  {
        server localhost:62755;
    }

    server {
        listen      80;
        server_name localhost;

        client_body_temp_path      D:/dev/nginx/client_body_temp;
        proxy_temp_path            D:/dev/nginx/proxy_temp;


        location / {
            root D:/dev/frontend/src;
            index index.html;
        }

        location /api {
            proxy_pass http://backend;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
        }
    }
}
windows
  • 1 1 个回答
  • 1234 Views

1 个回答

  • Voted
  1. Best Answer
    Astaar
    2015-05-12T11:38:16+08:002015-05-12T11:38:16+08:00

    我的问题是,即使在 CTLR+C'ing 时,nginx 实例也没有被杀死。我通过进入任务管理器找到了这个。显然旧实例保持旧版本的配置运行,并且是第一个拦截请求的,因此即使更改 nginx.conf,也不会应用更改。

    杀死所有已处理的东西,所以我的最新配置,我包含 mime.types 的配置被考虑在内,并解决了这个问题。

    • 2

相关问题

  • 知道任何适用于 Windows 的快速可编写脚本的 ftp 客户端吗?[关闭]

  • 如果 Windows 服务崩溃,如何自动重新启动它?

  • 无法安排任务(访问被拒绝)

  • 物理机重启时自动重启虚拟机(VMWare)

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve