Home > Net >  How to port NGINX config from IIS
How to port NGINX config from IIS

Time:10-27

I have a front controller setup on IIS which I need to convert to NGINX on Docker.

Basically on IIS I have a virtual directory /we which maps to the application code at /var/app/we. When file is requested, if its not found, it is rewritten to /we/index.cfm?path_info=/{R:0}.

E.g. if a user requests http://example.com/sub1/test.cfm it is rewritten as http://example.com/index.cfm?path_info=/sub1/test.cfm.

I have tried various things like setting up a virtual directory alias in NGINX like this

location /we {
    alias /var/app/we;
}

and then adding a rewrite rule but I just can't get it to work. Can someone please help?

The rule on IIS which I'm trying to convert is below:

 <rule name="Redirect the File" enabled="true">
      <match url="^(.*)$" />
       <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_URI}" pattern="^/(flex2gateway|jrunscripts|cfide|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|rewrite.cfm|index.cfm)" negate="true" />
       </conditions>
       <action type="Rewrite" url="/we/index.cfm?path_info=/{R:0}" appendQueryString="true" />
 </rule>

CodePudding user response:

You can try the script from this link: iis-to-nginx.

Automated script to convert IIS rewrite rules to nginx rewrite format the code convert rewrite IIS rules to nginx rewrite format, you can import the output into the nginx config file.

CodePudding user response:

You can try the script from this link: iis-to-nginx.

Automated script to convert IIS rewrite rules to nginx rewrite format the code convert rewrite IIS rules to nginx rewrite format, you can import the output into the nginx config file.

  • Related