We app is terminated automatically at Windows server - go

I've my go app the is running a web API and working smoothly at my laptop.
I read this and completed the IIS setup using a config file:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:9000/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
And copied the compiled file at the same location, but once I gone for the url I got nothing, and once I run the .exe file I got it terminated quickly!
Any idea how to be able to run this execuatble file at MS server.
UPDATE
If I removed the binding at the server, then the app is working fine, it looks this binding process is blocking the port!

Related

IIS setup with Vuejs and Laravel

In my Laravel + Vuejs project I have the following structure:
wwwroot/dist folder where the client application is located in /wwwroot/dist.
wwwroot/public folder, entry point of Laravel
The client application consumes a Laravel REST API. There are also other APIs for different utilities.
I have the following web.config file in /wwwroot. The idea is that all requests go to /dist to access the client app, except those coming from the api|src|flyer|admon|user subdomains. This is my web.config:
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="/public/index.php" />
<add value="/dist/index.html" />
</files>
</defaultDocument>
<handlers accessPolicy="Read, Execute, Script">
</handlers>
<rewrite>
<rules>
<rule name="specific routes" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern=".*(api|src|flyer|admon|user)\.mysite\.com.*" />
</conditions>
<action type="Rewrite" url="/public/index.php" appendQueryString="True" />
</rule>
<rule name="general routes" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="/dist/" appendQueryString="True"/>
</rule>
</rules>
</rewrite>
</system.webServer>
All requests that work with the first rule (api|src|flyer|admon|user subdomains) work correctly. The issue is that my client app doesn't work, it seems like it doesn't process Javascript files. Note that in the content of the JS files it shows that of index.html:
The problem is not in my Vuejs application, because I have it installed on another Apache/Linux machine and everything works correctly with the same deployment structure.
EDIT
This is my virtual path config in Azure, where my web.config is placed:

web.config to run dist folder deployed on azure app service via FTP

I am using Vue CLI project and wants to deploy the dist folder to Azure App Service via FTP but I am missing with web.config file to run my deployed app service.
I am trying to do this answer but can't find a web.config file for my reference.
Thanks in advance for your answers.
FTP deployment doesn't support build automation like:
generation of web.config
dependency restores (such as NuGet, NPM, PIP, and Composer automations)
compilation of .NET binaries
Generate these necessary files manually on your local machine, and then deploy them together with your app.
Add web.config file with a URL Rewrite rule
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Vue CLI generated projects are configured to copy anything in the public folder directly into the build output directory (dist by default).
Put it in /public It will then be copied over to /dist during build.
I have created the config file in public folder, After running npm run build , web.config file is copied to dist folder.
To create web.config,Right click on the public folder-->Add new file, name it as web. Config and add the above mentioned code snippet and save.
Go to Azure portal, your Web App =>Advanced Tools=>KUDU - Debug Console =>CMD =>
site=>wwwroot ,
check if web.config file exists or not.

Host header (SERVER:) and URL Rewrite

I want to hide the IIS version in my web server response. I am trying to do this via URLRewrite for my website.
My web.config looks like so:
<rewrite>
<outboundRules>
<rule name="RewriteServerSoftware" stopProcessing="true">
<match serverVariable="SERVER_SOFTWARE" pattern="." />
<action type="Rewrite" value="MyServer" replace="true" />
</rule>
</outboundRules>
</rewrite>
This however does not seem to remove the value of Server:Microsoft-IIS/8.0. What might I be missing?
My environment is Windows Server 2012 R2 and IIS 8.0, hosting an ASP.NET website
The correct server variable name is: RESPONSE_Server which follows the RESPONSE_headername format.
So your config should be:
<rewrite>
<outboundRules>
<rule name="RewriteServerSoftware" stopProcessing="true">
<match serverVariable="RESPONSE_Server" pattern=".+" />
<action type="Rewrite" value="MyServer" replace="true" />
</rule>
</outboundRules>
</rewrite>
One additional thing to note is that if you're using IIS 10.0 you also might need to add the following to your web.config:
<system.webServer>
<security>
<requestFiltering removeServerHeader="true" />
</security>
</system.webServer>
In my case with IIS 10.0 only using both URL-Rewrite and the removeServerHeader worked.
More Info: https://learn.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/

Can I redirect all IE8 users for all sites on a server?

I have W2008 running IIS and have about 20 websites (all PHP, about half are WP) running on it.
Currently I have this in the header on a few sites and it is working. But it is getting hard to manage because even though I am the admin there are a lot of developers and they could overwrite the header if they wanted on most sites.
<!--[if IE 8]>
<script type="text/javascript">
window.location = "http://example.com/wedontsupportIE8.html";
</script>
<![endif]-->
Is there a way to set up a rule on the server that would have the same functionality?
ADDED NOTE:
I have added rules on web server and they basically don't work right. I had the redirect to /home/index.php already working for the past 6 months. When I add the new rule first it does the following:
in IE8 - 404 error for any directory on site and it reverts to the root
in IE10, FF, Chrome, Safari - it just redirects to /home as it should.
webconfig below
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="IE8rewriteall" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="*MSIE*" />
</conditions>
<action type="Rewrite" url="http://example.com/ie/index.html" />
</rule>
<rule name="Root Hit Redirect" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/home/index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This should do it. Have to install a iis7 plugin URL Rewriter though. IIS7 OOB can't do it.
URL Rewriter
Hope this helps

web.config rewrite rule in Child folder

I've a simple site with a web.config file for rewriting URL's
for instance, navigating to www.domain.com/story will show the page at www.domain.com/story.php
I've added a child folder with a copy of the site with a Chinese translation to www.domain.com/zh
I can access the story page at www.domain.com/zh/story.php but not www.domain.com/zh/story
How do I need to configure my web.config file? I've tried copying the web.config file to the /zh folder but this doesn't work, I've also tried copying and changing my match URL from ^story to ^zh/story but this also doesn't have the desired effect. Can someone suggest what is going on please?
Here is my existing web.config in the web root:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to story.php">
<match url="^story" />
<action type="Rewrite" url="story.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Haven't had a chance to try myself, but try something like this:
<rule name="Rewrite to story.php">
<match url="^zh/story" />
<action type="Rewrite" url="zh/story.php" />
</rule>

Resources