IIS Multiple Websites access with name - iis

i have two django websites in CGI in my IIS WebServer that are binded with two different ports: 8080 and 8081, i need to access them with something like: myserver/app1 and myserver/app2.
How i can do this?
Many thanks

Solved using this approach:
In Urls.py i've added a wrapper for all requests with these lines of code:
urlpatterns = [
url(r'^(?i)subDirectory/', include([ #Application Prefix in Webserver
url(r'^(?i)$', app.views.home, name='home'),
url(r'^(?i)home', app.views.home, name='home'),
url(r'^(?i)contact', app.views.contact, name='contact'),]
Then modified the Static_Url property under settings.py:
STATIC_URL = '/subDirectory/static/'
Then in IIS, under the main website i've added a new webapplication with the defaultAppPool and configured like indicated here (Omitting the point n°4): https://azure.microsoft.com/it-it/documentation/articles/virtual-machines-windows-classic-python-django-web-app/
And added a virtual directory (under the application) in order to serve the statics (with caching rule fixed at 7 days) files with the following web config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
With this approach, you'll be able to use a main site and place/serve multiple django applications without become crazy!
Enjoy!

Related

Remove duplicate files from IIS for same application

I have X the same applications in IIS(some code/exe, but different config file).
Would it be possible to put duplicate files to some folder?
For example I have applications:
Canada.weather.com
usa.weather.com
mexico.weather.com
Uses same .dll and .exe, but have different config.
As Lex says, we don't suggest you to put duplicate files to some folder. If one of the dll is missed or not, it will make all the sites down.
If you still want to do this , you could apply the setting in applicationHost.config and wrapping it in a tag.
The applicationhost.config file path :
%windir%\system32\inetsrv\config\applicationHost.config
Each sites will have its own location, you could add the custome configuration inside each location tag.
Like belowl, I enable the windows auth for "BrandoTestSite":
<location path="BrandoTestSite">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
Notice: This way is lower maintainability. We don't suggest you choose this way to manage mutiple application.

Configure well-known folder in MVC 5 Web App?

I'm having problems creating and accessing a well-known folder in an MVC 5 Web App. I need the folder to house some documents for iOS and Android mobile apps.
First, I add a well-known folder to my MVC 5 Web App. I could not add a .well-known folder. Since I could not add the "." in front of the folder, I added a virtual directory using the Azure Portal.
This seems to work, but When I try to access the files using https://portal.mydomain.com/.well-known/apple-app-site-association or this https://portal.mydomain.com/.well-known/assetlinks.json, I get the following message.
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
When I try to access just the directory using https://portal.mydomain.com/.well-known/ I get the following message.
"You do not have permission to view this directory or page."
Finally, I added this to my web.config in order to handle the lack of a file extension on the apple-app-site-association file.
<staticContent>
<mimeMap fileExtension="." mimeType="application/octet-stream" />
</staticContent>
Any help is much appreciated. Thanks!
I added a new web.config file to my well-known folder and configured it like so. I can now access both files. This is a new web.config and has nothing to do with the web.config in the root directory. Using this config, the apple-app-site-association downloads a file when I access it using a web browser. The assetlinks.json file displays in the web page, so they behave differently.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension="." mimeType="application/octet-stream" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
I commented out this entry in my root directory web.config because I did not need it.
<staticContent>
<mimeMap fileExtension="." mimeType="application/octet-stream" />
</staticContent>

At what point in the run-time process does IIS compress output?

I recently tried to integrate WebMarkupMin, a run-time html minification library, into my site (C#, IIS 8, MVC 4). We have IIS compression enabled. I discovered that IIS actually compresses the action filter output stream, which means when I try to minify my html in an action filter, I am trying to minify already compressed content.
Question: At what point in the run-time process does IIS compress output? Is there any way to use mvc action filters to modify html ouptut without disabling IIS compression?
The IIS dynamic compression for ASP MVC output runs pretty late in the pipeline. In my test it was No. 315 out of 349 pipeline items and after all the asp.net modules ran.
To see the order of the executed modules in the IIS pipeline, set up Failed Request tracing (FREB) for your site and review the logs.
I would say there is no way in your MVC action filter to tell the compression module not to compress.
But you can turn compression off on a url basis:
In your web config use something like this:
<location path="my/long/route/">
<system.webServer>
<urlCompression doDynamicCompression="false" />
</system.webServer>
</location>
you are telling IIS to turn off dynamic compression for just that URL.
It is necessary assign to dynamicCompressionBeforeCache attribute a value equals to false:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
…
<system.webServer>
…
<httpCompression …>
…
</httpCompression>
<urlCompression … dynamicCompressionBeforeCache="false" />
…
</system.webServer>
…
</configuration>
I know this is an old issue but the error solved when I used UseResponseCompression before UseStaticFiles
app.UseResponseCompression();
app.UseStaticFiles(new StaticFileOptions
{
ServeUnknownFileTypes = true,
OnPrepareResponse = context => context.Context.Response.Headers.Add("Cache-Control", "public, max-age=2592000")
});
app.UseWebMarkupMin();

web.config causes HTTP 500 issue with virtual directory in IIS

I'm fairly new to IIS so apologies if this is a basic question.
I have an IIS config serving an internal company website (php instead of asp.net). The prod version of the website is at the 'Default Web Site' level and I've got demo and test versions of the website mapped as virtual directories. The demo and test version are essentially copies of the prod directory. I've noticed the with the web.config copied to these VDs, I get an error 500 on the root url for the VD only. I.E. main website is https://mainwebsite.com and works fine but https://mainwebsite.com/demo/ doesn't work while https://mainwebsite.com/demo/index.php works fine.
The web.config file is pretty basic:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
</handlers>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:03:00" />
</staticContent>
</system.webServer>
</configuration>
Moving the web.config file out of the way in the VD resolves the issue. Even though the files are identical, I wouldn't think that the file should cause a conflict as my understanding is that IIS supports multiple web config files.
Although I have a workaround in place by renaming or deleting the file, I am wondering if there's a way to keep the file in place without it causing this error.
Thanks to Panama Jack in the comments, I was able to resolve my issue.
I got this response with detailed errors:
Error Summary
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
And further down:
Config Error
Cannot add duplicate collection entry of type 'add' with unique key attribute 'value' set to 'index.php'
To resolve, I simply commented out this line in the web.config XML:
<add value="index.php" />
I'm sure there's a better way to approach this but for now, this gets me my answer and also how to get more info from IIS when the logs are not useful.
if you create a virtual directory to another web root
web.config will cause this (personally I think the location of this file is totally insane.. mixed with htm and images etc. )
Replicate the directory somewhere else without the web.config file/excluding it..then point the virtual directory there.. & have a task set up to copy newer files over..

iis only Add Expires headers to images

Add expires headers in iis is very Easy,but this cache all the static files. now i want only
add expires headers to images,how can i do that? even i want cached specific file?
put all your images in one folder
enter the manager--> yoursite--> images folder (or specific file)
right click--> HTTP HEADERs--> Set expire header/date ! --> APPLY/OK
I've been searching for a simpler solution and I found this.
Keep your static content inside a folder (eg: css, js). Create a web.config file inside that folder. Add these following lines. Here 7 is the number of days, change it as you desire.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
You are free to keep as many static content folder as you want, simply add this web.config file. Hope this helps.

Resources