0

I have 1 subdomain in addition to the main website, all running on nginx + fastcgi-mono-server4.

PROBLEM: I have to make the subdomain use a different port (port 81) for all the .conf/.webapp files or else when i visit subdomain.example.com, it always displays content for example.com instead. There seems to be a problem in my .webapp file. Displaying correct website works partially if I "hack" it and use port 81 for the subdomain: https://stackoverflow.com/questions/28872585/how-to-handle-multiple-websites-through-fastcgi-server

Below are nginx .conf files for each website:

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

Next are the .webapp files required by fastcgi-mono-server4, (BOTH are in same folder /nginx/webapps):

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

To get the fastcgi-process started I run the following command:

fastcgi-mono-server4.exe --appconfigdir /nginx/webapps /socket=tcp:127.0.0.1:9000 /logfile=/opt/nginx/logs/fastcgi.log &
invulnarable27
  • 183
  • 1
  • 3
  • 8

1 Answers1

0

Thought I'd update my findings and post what I ended up doing. The service fastcgi-mono-server4 can't do intelligent routing like nginx, so we either have to use the <vport> or <vpath> in the .webapp file to do the redirection. I ruled out the <vport> (:81) because it looks ugly and having to open port 81 in the firewall is a no go.

So the lesser of two evils and the solution I ended up using is to add a small path addition to both nginx.conf and .webapp files (adding path "/m" to files)

The final url will be: 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;
    }

Contents of .webapp file:

##### 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>
invulnarable27
  • 183
  • 1
  • 3
  • 8