2

我正在尝试在运行 nginx 和 fastcgi-mono-server4 的 Debian 7 服务器上激活 HTTPS。我也使用 ServiceStack。

当我使用端口 80(非 SSL)时,一切正常。当我将其更改为端口 443 (SSL) 时,当我尝试调用服务器时出现错误。错误是:

No Application Found

Unable to find a matching application for request:

    Host    business.myserver.com
    Port    443
    Request Path    /api
    Physical Path   /var/www/business.myserver.com/api

这是我的 nginx.conf 文件:

    server {
            listen 443 ssl;

            fastcgi_param HTTPS on;

            ssl_certificate /etc/nginx/ssl/nginx.crt;
            ssl_certificate_key /etc/nginx/ssl/nginx.key;

            server_name business.myserver.com;
            root /var/www/business.myserver.com;

            location /api {

                    error_log /var/log/nginx/api-error.log;

                    #add_header Access-Control-Allow-Origin "*";
                    add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
                    add_header Access-Control-Max-Age 1728000;
                    add_header Access-Control-Allow-Headers "Origin, Content-Type, Authorization";
                    #add_header Access-Control-Allow-Credentials "true";

                    index index.html index.htm default.aspx Default.aspx;

                    fastcgi_index /api;
                    fastcgi_pass 127.0.0.1:9000;

                    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 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;

                    fastcgi_param PATH_INFO "";
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                    # HACK: something is causing ServiceStack / ASP.Net -> Mono -> FastCGI
                    # to encode 'deflate' again, so force request to disallow gzip or deflate
                    fastcgi_param HTTP_ACCEPT_ENCODING "";
            }
    }

任何帮助或提示将不胜感激。

4

1 回答 1

1

我有同样的问题,但在我的情况下,它来自fastcgi-mono-server4's 的配置。

当您运行该命令时,您指定一个配置文件夹。就像是

fastcgi-mono-server4 --appconfigdir '/var/www/mono-fastcgi ...'

该文件夹/var/www/mono-fastcgi包含.webapp配置文件。您需要确保在那里侦听端口 443。例如 :

<apps>
  <web-application>
    <name>aspnet</name>
    <vhost>my/application.com</vhost>
    <vport>443</vport>
    <vpath>/</vpath>
    <path>/srv/www/aspnet</path>
  </web-application>
</apps>

就我而言,<vport>是 80,这就是导致此错误的原因。

于 2016-01-28T20:50:03.483 回答