我有一个子域,除了主要的网站,所有运行在nginx +快速all mono服务器4。
问题:我必须让子域对所有..conf/..webapp文件使用不同的端口(端口81),否则当我访问subdomain.example.com时,它总是会显示example.com的内容。我的.webapp文件中似乎有一个问题。如果我“黑”它并使用端口81作为子域:https://stackoverflow.com/questions/28872585/how-to-handle-multiple-websites-through-fastcgi-server,则显示正确的网站部分工作。
以下是每个网站的nginx .conf文件:
##### SUBDOMAIN #####
server {
server_name subdomain.example.com;
root /subdomain;
listen 81;
location / {
fastcgi_index Default.aspx;
fastcgi_pass 127.0.0.1:9000;
include /opt/nginx/conf/fastcgi_params;
}
##### MAINWEBSITE #####
server {
server_name example.com;
root /mainwebsite;
listen 80;
location / {
fastcgi_index Default.aspx;
fastcgi_pass 127.0.0.1:9000;
include /opt/nginx/conf/fastcgi_params;
}下面是快速are mono 4所需的.webapp文件(都位于同一个文件夹/nginx/webapp中):
##### SUBDOMAIN #####
<apps>
<web-application>
<name>subdomain</name>
<vhost>*</vhost>
<vport>81</vport>
<vpath>/</vpath>
<path>/subdomain</path>
</web-application>
</apps>
##### MAINWEBSITE #####
<apps>
<web-application>
<name>subdomain</name>
<vhost>*</vhost>
<vport>80</vport>
<vpath>/</vpath>
<path>/mainwebsite</path>
</web-application>
</apps>为了启动快速run进程,我运行以下命令:
fastcgi-mono-server4.exe --appconfigdir /nginx/webapps /socket=tcp:127.0.0.1:9000 /logfile=/opt/nginx/logs/fastcgi.log &发布于 2015-11-16 23:04:50
我想我会更新我的发现并发布我最后所做的事情。服务fastcgi-mono-server4不能像nginx那样进行智能路由,因此我们要么必须使用.webapp文件中的<vport>或<vpath>来进行重定向。我排除了<vport> (:81),因为它看起来很难看,而且必须在防火墙中打开端口81是不可能的。
因此,我使用的解决方案是在nginx.conf和.webapp文件中添加一个小路径(将路径"/m“添加到文件中)。
最终的网址是: subdomain.example.com/m
##### SUBDOMAIN #####
server {
server_name subdomain.example.com;
listen 80;
//Addition of "/m" for location
location /m {
root /mainwebsite;
fastcgi_index Default.aspx;
fastcgi_pass 127.0.0.1:9000;
include /opt/nginx/conf/fastcgi_params;
}.webapp文件的内容:
##### SUBDOMAIN #####
<apps>
<web-application>
<name>subdomain</name>
<vhost>*</vhost>
<vport>80</vport>
<vpath>/m</vpath> //Addition of "/m" for <vpath>
<path>/subdomain</path>
</web-application>
</apps>https://serverfault.com/questions/736447
复制相似问题