【问题标题】:While trying to start my fastcgi-mono-server I get a permission error尝试启动我的 fastcgi-mono-server 时出现权限错误
【发布时间】:2017-11-13 06:38:21
【问题描述】:

我使用这个命令来启动我的服务器:

fastcgi-mono-server4 -v /applications=www.testjet123.com:/:/usr/share/nginx/TestJet/ /socket=unix:/tmp/fastcgi.socket

一切正常,服务器没有停止,但在输出结束时出现此错误:

[2017-11-13 06:29:00.445497] Notice : Adding applications 'www.testjet123.com:/:/usr/share/nginx/TestJet/'...
[2017-11-13 06:29:00.454111] Notice : Registering application:
[2017-11-13 06:29:00.454177] Notice :     Host:          www.testjet123.com
[2017-11-13 06:29:00.454193] Notice :     Port:          any
[2017-11-13 06:29:00.454204] Notice :     Virtual path:  /
[2017-11-13 06:29:00.454216] Notice :     Physical path: /usr/share/nginx/TestJet/
[2017-11-13 06:29:00.466032] Error  : Error parsing permissions "". Use octal.

fastcgi_params 是默认值:

#ASP.NET
#fastcgi_param  PATH_INFO          "/usr/share/nginx/TestJet/";
#fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;


fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

这是我的nginx 配置:

server {
    listen  80;

    server_name testjet123.com www.testjet123.com  

    location / {
        root  /var/www/UI/html;
        index  index.html index.htm;
        try_files $uri $uri/ =404;
    }

    location ~ \.(aspx|asmx|ashx|asax|ascx|soap|rem|axd|cs|config|dll)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

但是,当我使用 TCP 套接字而不是 UNIX 套接字时,我没有收到错误,请参见下文:

fastcgi-mono-server4 -v /applications=www.testjet123.com:/:/usr/share/nginx/TestJet/  /socket=tcp:9000
[2017-11-13 06:36:09.160760] Notice : Adding applications 'www.testjet123.com:/:/usr/share/nginx/TestJet/'...
[2017-11-13 06:36:09.169121] Notice : Registering application:
[2017-11-13 06:36:09.169187] Notice :     Host:          www.testjet123.com
[2017-11-13 06:36:09.169202] Notice :     Port:          any
[2017-11-13 06:36:09.169213] Notice :     Virtual path:  /
[2017-11-13 06:36:09.169225] Notice :     Physical path: /usr/share/nginx/TestJet/

我正在使用 RHEL 7。

【问题讨论】:

    标签: sockets nginx mono fastcgi rhel7


    【解决方案1】:

    尝试将/filename=/tmp/fastcgi.socket 参数与/socket=unix 一起使用,以代替组合的/socket=unix:/tmp/fastcgi.socket 参数。我发现这已经解决了基于 debian 的发行版的问题。

    您需要设置权限,以便 nginx (www-data) 组使用:chmod 660 /tmp/fastcgi.socketchgrp www-data /tmp/fastcgi.socket 对套接字进行读写访问。

    虽然有点离题,但我个人的经验和最初从tcp/ip 套接字转移到unix 套接字的原因是由于 nginx 和 mono 服务之间的连接在一段时间或一段时间后突然断开连接要求。导致入站请求挂起/失败。

    我在使用 HyperFastCGI 时遇到了同样的问题,但是使用 unix 套接字对 HyperFastCGIfastcgi-mono-server4 都没有帮助。

    事实证明,这是因为我直接使用了来自 mono 开发人员 repo 的最新软件包,它安装了 mono 版本 5.10.1。重新构建机器并仅使用基于 debian 的发行版提供的单声道包,安装单声道版本4.6.2,解决了我的问题。 asp.net 进程不再与 nginx 服务分离或断开连接。

    另外,根据:https://www.nginx.com/resources/wiki/start/topics/examples/mono/ 建议使用unix 套接字:

    您也可以将其绑定到推荐的 UNIX 套接字。

    由于这个建议,我继续使用unix 套接字在 nginx 和fastcgi-mono-server4 服务之间进行通信,并选择不使用HyerfastCGI。我不再遇到 nginx 和 mono 进程之间的任何连接丢失或中断;连接在许多天和任意数量的请求中都是稳定的。事实上,到目前为止,我还没有经历过任何损失。也没有其他用户报告的使用fastcgi-mono-server 的内存泄漏形式。

    【讨论】:

      猜你喜欢
      • 2018-11-19
      • 2022-01-12
      • 2019-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-04
      • 2017-10-27
      • 1970-01-01
      相关资源
      最近更新 更多