I'd like to have environment-specific application settings in my Java/Tomcat web app. When I developed in .NET on IIS I had the good old web.config file to help me out with this. Does Tomcat have something equivalent to IIS's web.config file?
web.config is basically the application's config file. So in Tomcat/Java EE it's the web.xml which is part of the webapp.
Related
I'm working aroung IIS config files.
I want add some IIS IP address restrictions at server level, that spread over all the IIS appPolls
If I work with IIS Manager all work fine, I'm able to add any config settings. But if I want modify/add them directly on .config file it is no possible.
I can see that the settings made by IIS Manager are written on a temporary .tmp file under C:\inetpub\temp\appPools and then overwritten on DefaultAppPool.config under C:\inetpub\temp\appPools\DefaultAppPool
If I try to manual modify DefaultAppPool.config it don't take effect on IIS Manager and if I make any changes on IIS Manager it is overwritten. If I try to manual modify the tmp config under C:\inetpub\temp\appPools I'm informed that the file is in use.
I've also try to work with applicationHost.config under C:\Windows\System32\inetsrv\config, but it does not seem to match the configuration displayed on IIS Manager.
So how can I edit the IIS configuration file manually at the server level?
I've to add a lot of IP restrictions and the only way is to add them directly on .config file.
Very thanks for any help
That is the temporary file. if you want to change the iis configuration at the server level then you could modify the iis applicationhost.config file.
ApplicationHost.config is the root file of the configuration system when you are using IIS 7 and above. It includes definitions of all sites, applications, virtual directories and application pools, as well as global defaults for the web server settings (similar to machine.config and the root web.config for .NET Framework settings).
Open notepad as administrator and open applicationhost.config
add below code in the config file:
<ipSecurity allowUnlisted="true">
<add ipAddress="192.168.2.52" allowed="true" />
</ipSecurity>
https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/introduction-to-applicationhostconfig
In legacy ASP.NET applications, *.config files cannot be downloaded by navigating to the URL. But the new convention is to use appsettings.json. Now, if I have a ASP.NET Core website called contoso.com and it's served by IIS from a directory called C:\inetpub\websites\contoso.com, and there is a file located at C:\inetpub\websites\contoso.com\appsettings.json... Is IIS smart enough to know not to serve this file over HTTP if someone navigates to https://contoso.com/appsettings.json?
Files are normally served from the "wwwroot" folder. The appsettings.json file is safe as long as you haven't configured C:\inetpub\websites\contoso.com\ to be your app's web root. By default, static files are found in C:\inetpub\websites\contoso.com\wwwroot\. I recommend this excellent doc: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files
By the way, unless configured otherwise, IIS doesn't even check the filesystem. It is actually ASP.NET Core that is going to ensure files are only served from the "wwwroot" folder. A typical ASP.NET Core website in IIS is actually running as a separate web server which IIS reverse proxies to via the ASP.NET Core Module. This means all requests are handled by ASP.NET Core. To serve static files, you have to use the static files middleware, which is available in the Microsoft.AspNetCore.StaticFiles package.
As for IIS, I have a PHP app, and I am using web.config for configuration.
When I change settings in web.config, shall I restart the server? or just refresh my webpage and expect settings to take place?
You don't need to explicitly restart server. Web.config is special file, any changes in it are watched FileWatcher and app pool is restarted automatically when you do changes in this file. So your app pool restarts on following things.
Any changes in web.config
Any changes in machine.config
Any changes in global.asax
Anything changes in bin directory or it's sub-directories
I'm developing an app. using Common.Logging (http://netcommon.sourceforge.net/index.html).
A simplified logging configuration (which is done in web.config) is as follows:
<configuration>
...
<arg key="configType" value="FILE" />
<arg key="configFile" value="NLog.config" />
...
</configuration>
As you can see here, the configuration points another configuration file (here, NLog.config) of a backend logging framework.
My question is: when deploying in Azure, what path should I specify here (on dev, NLog.config is copied when building the solution, and placed in the bin directory). In other words, what would be the SAFEST way to get the physical place where the app is deployed in Azure?
Thanks in advance!
In code you can find the current path to the application using Server.MapPath("/"). Now, you can simply make sure that the NLog.config file gets deployed to the application folder:
Add NLog.config to your project (in the root of your web application)
Change the Build Action to Content
In order to test this you can right click on your Azure project an choose Package. In the bin\Release|Debug\app.publish folder of your Azure project you'll find a *.cspkg file. Add a .zip extension to this file and open the file with WinRAR/ZIP/7zip/... Then you'll see a file like this one: SomeWebRole_1a91f39a-49b7-4ece-873f-862172a2fa06.cssx. Here again, add the .zip extension to this file and open it.
If you navigate to the sitesroot\0 folder you'll see the files of the web application in IIS, including the NLog.config file. This way, you' can simply reference the NLog.config file in the Common.Logging settings:
I have a default IIS 6 install and I can access only .html files. If I create a html file I can see it on the browser. Any other files like ini for example are not visible (404). Any idea on what can be the issue?
Check the web service extensions are enabled (in IIS below the websites is a folder for them) for the content you are trying to share.
Check that the handler mappings is setup correctly (on the website properties)
This may help :
IIS & ASP.NET blocking file