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 / 问题 / 630348
Accepted
Quandary
Quandary
Asked: 2014-09-23 07:36:38 +0800 CST2014-09-23 07:36:38 +0800 CST 2014-09-23 07:36:38 +0800 CST

为什么 google-site-verification 进入 fastcgi-pass ?

  • 772

请参阅下面的 nginx 配置文件。
基于虚拟名称的托管 (example.com),将 example.com 和 www.example com 的请求传递给端口 9000 (127.0.0.1:9000) 上的单声道 fastcgi-process

我添加了文件 google-site-verification,但是问题是,asp.net fastcgi-application 是一个 MVC 应用程序,所以它没有找到名为“google79af7e588a34905e0.html”的控制器。

我正在尝试覆盖虚拟主机配置文件中的位置,因此它不会将 google79af7e588a34905e0.html 的请求转发到 fastcgi 应用程序,但它不起作用。

我已经重新启动了 nginx,但它没有任何区别......
我做错了什么?我尝试删除“location = /”中的等号,但这不起作用,我尝试在主要位置之前移动位置覆盖,但这也没有什么区别。我也前后更改了主机名,只是为了看看我是否在正确的配置文件中,而且当我更改域名时,我开始得到 404。

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##


 server {
         listen   80;
         server_name www.example.com example.com;
         access_log   /var/log/nginx/your.domain1.xyz.access.log;




         location / {
                 root /home/example/www/homepage;
                 #index index.html index.htm default.aspx Default.aspx;
                 #fastcgi_index Default.aspx;
                 fastcgi_pass 127.0.0.1:9000;
                 include /etc/nginx/fastcgi_params;
         }



    #http://serverfault.com/questions/477103/how-do-i-verify-site-ownership-on-google-webmaster-tools-through-nginx-conf
    location = /google79af7e588a34905e0.html {
            rewrite ^/(.*)  $1;
            return 200 "google-site-verification: $uri";
    }




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

    location /shared_images {
        root /usr/share;
        autoindex off;
    }

    error_page 404 /CustomErrors/404.htm;

    # redirect server error pages to the static page /50x.html
    #
    #error_page 500 502 503 504 /50x.html;
    #location = /50x.html {
    #   root /usr/share/nginx/www;
    #}

}
nginx
  • 2 2 个回答
  • 1078 Views

2 个回答

  • Voted
  1. deagh
    2014-09-23T11:13:57+08:002014-09-23T11:13:57+08:00

    根定义上方的位置可以解决问题

    location /google79af7e588a34905e0.html {
        alias /your/local/path/to/google79af7e588a34905e0.html;
    }
    

    无需任何重写。

    • 2
  2. Best Answer
    Tero Kilkanen
    2014-09-23T14:18:08+08:002014-09-23T14:18:08+08:00

    我会选择这种设置:

    server {
        listen 80;
        server_name www.example.com example.com;
        access_log   /var/log/nginx/your.domain1.xyz.access.log;
    
        root /home/example/www/homepage;
    
        try_files $uri $uri/ @mvc;
    
        location @mvc {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
        }
    
        location /doc {
            alias /usr/share/doc;
            autoindex on;
            allow 127.0.0.1;
            deny all;
        }
    
        location /shared_images {
            alias /usr/share/shared_images;
            autoindex off;
        }
    
        error_page 404 /CustomErrors/404.htm;
    }
    

    这里我们使用 nginxtry_files指令来检查文件是否物理地存在于文件系统中。如果文件不存在,则将请求传递到 MVC 后端。

    我还用root指令替换了位置内部的alias指令,因为这使配置更直观,至少我是这样看的。

    此设置还使 nginx 服务器成为所有静态资产,而不是让 MVC 后端也处理这些请求。您可能需要调整主server块root指令。

    但是,此设置需要文件系统上的实际文件。

    • 1

相关问题

  • 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