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 / 问题 / 432598
Accepted
Chris Muench
Chris Muench
Asked: 2012-09-28 07:00:06 +0800 CST2012-09-28 07:00:06 +0800 CST 2012-09-28 07:00:06 +0800 CST

nginx配置文件解释

  • 772

我对 /etc/nginx/sites-enabled 中的这个配置文件“默认”有几个问题。它如下所示。

server 
{
  root /usr/share/nginx/www;
  index index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

location / {
    proxy_pass http://127.0.0.1:8080;
}

location /doc {
    root /usr/share;
    autoindex on;
    allow 127.0.0.1;
    deny all;
}

location /images {
    root /usr/share;
    autoindex off;
   }
}
  1. 没有“Listen”指令,它怎么知道默认为 80
  2. server_name 是 localhost,另一个域如何工作?
  3. 为什么位置指令嵌入在服务器指令中?这是否意味着这些位置仅适用于此服务器?
  4. 我的配置都没有 listen 80 default_server;nginx 如何选择要使用的配置?
nginx
  • 1 1 个回答
  • 1417 Views

1 个回答

  • Voted
  1. Best Answer
    Maxim Dounin
    2012-09-28T23:53:21+08:002012-09-28T23:53:21+08:00

    只是一个快速的免责声明:站点启用/站点可用布局不是来自 nginx 本身,而是来自您的包维护者。默认情况下,nginx 提供单个 nginx.conf 示例配置,这比include某些 linux 包中的多个文件连接更明显。以下是按顺序回答:

    没有“Listen”指令,它怎么知道默认为 80

    这是因为 nginx 默认侦听端口 80(如果以非 root 身份运行则为 8000),请参阅http://nginx.org/r/listen。

    server_name 是 localhost,另一个域如何工作?

    默认情况下,nginxserver在配置中使用 first 作为默认配置(并使用它来处理与其他服务器server_name指令不匹配的域)。只要 sites-enabled/default 是您配置中唯一的服务器 - 它实际上将作为默认服务器运行。如果您要添加更多服务器 - 它可能会中断。请参阅http://nginx.org/en/docs/http/request_processing.html上的详细说明。

    为什么位置指令嵌入在服务器指令中?这是否意味着这些位置仅适用于此服务器?

    是的,location指令可能仅在某些特定范围内指定server,并且仅适用于与此服务器匹配的请求。

    我的配置都没有 listen 80 default_server;nginx 如何选择要使用的配置?

    在配置中找到的第一个服务器块将是默认值。由于include通配符不强加任何顺序,它可能是一些随机服务器块。

    • 3

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

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