Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

Monday, June 11, 2018

IIS URL redirect error

When you are using iis to redirect  proxy IIS Return 404.4 Not Found when URL Rewrite on some pages , but page exists.

Open IIS rewrite web.config  file  and add inside the <system.webServer> tag, add the following:

<security>
<requestFiltering allowDoubleEscaping="true" />
</security>

Wednesday, December 6, 2017

Clear IIS logs using powershell script

get-childitem -Path c:\inetpub\logs\logfiles\w3svc*\*.log -recurse |
where-object {$_.lastwritetime -lt (get-date).addDays(-30)} |
Foreach-Object { del $_.FullName }

Wednesday, September 13, 2017

Port forwarding on WIndows Server

run cmd as Administrator

netsh interface portproxy add v4tov4 listenaddress=YOUR_IP_HERE listenport=8080 connectaddress=YOUR_IP_HERE connectport=80

to view proxy rules use this command:

netsh interface portproxy show all


tocheck use this command:

netstat -ano | findstr :<listenport number>

To delete this rule use command:

netsh interface portproxy delete v4tov4 listenaddress=YOUR_IP_HERE listenport=8080 connectaddress=YOUR_IP_HERE connectport=80





Thursday, August 31, 2017

Install a Windows service using a Windows command prompt

run CMD as Administrator:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"

Wednesday, February 15, 2017

Permission to read private key IIS Server

You need the permission to read private key for IIS Server.

   1.Go to this path:  C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys[File Name]

  1. Go to that path and open file properties
  2. Go to security tab
  3. Click on "Edit" then "Add"
  4. Add  users "Network Service" and "IIS_IUSRS" and give Full controll Permitions.
or add  IIS AppPool\[your application pool name]

Friday, January 27, 2017

View IIS Errors


Open Web.config file on the IIS  site -> There you need to search for CallStack and change CallStack = “true” 
Similarly search for CustomError and change CustomError =”Off” 

That’s it you can now browse the page where you are facing the issue and then you will be able to know the root cause of the error and then accordingly handle it.

Friday, January 13, 2017

Remove IIS Logs Script

Script to remove IIS logs:


$start = (get-date).AddDays(-30) 
Get-ChildItem -Path c:\inetpub\logs\logfiles\w3svc*\*.log | where {$PSItem.LastWriteTime -lt $start} | Remove-Item

Add this sctipt to windows scheduler, and logs will be remove automatically!

Friday, November 4, 2016

Install Failover IIS Cluster using Powershell

   Check installed rolles NLB and IIS
Get-WindowsFeatute -name NLB,web-server

  Install roles web server and nlb on 3 servers from 1 console:
Invoke-Command –ScriptBlock {Add-WindowsFeature –Name NLB, web-server,wb-asp-net,webapp-dev,Web-ISAPI-Filter -IncludeManagementTools} –Computername iis01,iis02,iis03

  Create Nlb Cluster:
New-NlbCluster –hostname iis03 –OperationMode Multicast –ClusterName nlb01 –InterfaceName ethernet0 –ClusterPrimaryip 192.168.128.50 –SubnetMask 255.255.255.0

  Show NLB cluster
Get-NLBcluster –hostname iis03
$NLB= Get-Nlbcluster –hostname iis03

  ADD nodes to NLB cluster :
Add-NlbClusterNode –InputObject $Nlb –NewNodeName iis01 –newNodeInterface Ethrnet0
Add-NlbClusterNode –InputObject $Nlb –NewNodeName iis02 –newNodeInterface Ethrnet0

  Open TCP 80 port on firewall :
Set-NlbClusterPortRule –HostName iis03 –NewStartport 80 –NewEndPort 80

  ADD Dns record for cluster name :

Add-DnsServerResourceRecordA –ZoneName corp.local –Name nlb01 –Ipv4address 192.168.128.50