首页 > 解决方案 > NGINX 不会在自定义目录中提供 html

问题描述

我有以下配置。

events {}

http {
    include mime.types;

    server {
        listen 80;
        root /home/john/example;
        server_name example.com;     # <----------- I want this to work!
        index index.html;
        location / {
            try_files $uri $uri/ =404;
        }
    }

    server {
        listen 80;
        root /home/john/app;
        server_name app.domain.com;
        location / {
            proxy_pass 'http://127.0.0.1:3000';
        }
    }

    server {
        listen 80;
        root /home/john/admin;
        server_name admin.domain.com;
        location / {
            proxy_pass 'http://127.0.0.1:3001';
        }
    }
}

index.html文件位于/home/john/example目录中。

无论我尝试什么,添加配置并重新加载它,example.com 都不会返回任何内容。

其他的(proxy_passes)正常工作。

我做错了什么,一切都完全按照指南所说的那样。

请注意,同一台服务器上有两个域,这不是错字。

标签: nginx

解决方案


推荐阅读