YII2 An internal server error occurred in IIS 8.5 - iis-8

I used composer to successfully install and run yii2 version 2.0.10 in my laptop using xampp but when I installed it in windows server 2012 r2 with IIS v 8.5, it shows An internal server error occurred error. I did not change or edited any of the files from the fresh installation.
I tried renaming the index.php and created new index.php with just simple echo and it worked fine.
EDIT - here is the server log.
#Software: Microsoft Internet Information Services 8.5
#Version: 1.0
#Date: 2017-01-05 23:56:51
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2017-01-05 23:56:51 ::1 GET /advanced/frontend/web/ - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 http://localhost/advanced/frontend/ 500 0 0 5893
2017-01-05 23:56:56 ::1 GET /advanced/ - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 200 0 0 21
2017-01-05 23:56:59 ::1 GET /advanced/frontend/ - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 http://localhost/advanced/ 200 0 0 3
2017-01-05 23:57:01 ::1 GET /advanced/frontend/web/ - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 http://localhost/advanced/frontend/ 500 0 0 103
2017-01-05 23:59:35 ::1 GET /advanced/frontend/web/ - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 http://localhost/advanced/frontend/ 500 0 0 61
2017-01-05 23:59:35 ::1 GET /favicon.ico - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 http://localhost/advanced/frontend/web/ 404 0 2 10
EDIT 2.
Tried installing new one under development and it now gave different error.

Normally Yii is .htaccess for its mod-rewrite configuration. Do you convert it to an equivalent web.config so IIS can interpret it?

You need to add a web.config file in frontend/web/ and in the backend/web/
IIS Does Not Support .htaccess Files
Content of web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="Hide Yii Index" stopProcessing="true">
<match url="." ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile"
ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory"
ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Related

IIS URL Re-Direct to local host and port

I'm in the process of breaking apart and migrating an apache internal webserver to an IIS web server.
I believe what the snippet of apache web config does below when testing is re-direct any requests coming in from "bobby" to http://localhost:8181/
bobby is a DNS entry on our domain which resolves to 192.168.8.50.
In short, if you place bobby/ into a web browser on our domain without the port specified the below will forward to local host with the correct port.
How can I replicate this in IIS?
<VirtualHost 192.168.8.50:80>
ServerName bobby
ProxyRequests Off
ProxyVia Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://localhost:8181/
ProxyPassReverse / http://localhost:8181/
</VirtualHost>
Do you mean you want to redirect all the request from the "bobby" to "http://localhost:8181/"?
If this is your requirement , I suggest you could try to use IIS url rewrite module IIS reverse proxy to achieve your requirement.
You could install it from this url.
Then you could add below config settings in the bobby web.config file in system.webServer tag.
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:8181/{R:1}" />
</rule>
</rules>
</rewrite>

Apache clustering and load balancing with tomcat 8 in ubuntu

I want to do clustering and load balancing for my applications running in tomcat. I am using ubuntu, apache version 2.4.18 and two tomcat 8.5 instances. I tried with mod_jk for this but it is not working for me.
following is my configuration in apache and tomcat
in jk.conf
<IfModule jk_module>
JkWorkersFile /etc/apache2/conf/workers.properties
JkLogFile /etc/apache2/log/mod_jk.log
JkLogLevel info
JkShmFile /etc/apache2/log/jk-runtime-status
JkWatchdogInterval 60
JkMount /clusterjsp/* loadbalancer
JkMount /jk-status status
<Location /jk-status>
JkMount jk-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
<Location /jk-manager>
JkMount jk-manager
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</IfModule>
in workers.properies
worker.list=loadbalancer,status
worker.server1.port=8009
worker.server1.host=127.0.0.1
worker.server1.type=ajp13
worker.server1.connection_pool_size=200
worker.server1.connection_pool_timeout=600
worker.server1.socket_keepalive=1
worker.server2.port=7009
worker.server2.host=127.0.0.1
worker.server2.type=ajp13
worker.server2.connection_pool_size=200
worker.server2.connection_pool_timeout=600
worker.server2.socket_keepalive=1
worker.server1.lbfactor=1
worker.server2.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=server1,server2
worker.status.type=status
and in both tomcat server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="server1"> <!-- server2 for another instance -->
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">
<Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true"/>
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="4000" autoBind="100" selectorTimeout="5000" maxThreads="50"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
i did not make any changes in apache2.conf or i don't have httpd.conf in apache home directory. i have deployed same application i both tomcat servers and it is working when using http://localhost:8080/clusterjsp and http://localhost:7070/clusterjsp but When i type http://localhost/clusterjsp in my browser it gives me 404 error but http://localhost shows apache default page.
Can you please let me know what i am missing or what is wrong in my configuration.
Probably it is due to the fact that you are redirecting all incoming requests matching /clusterjsp/* to load balancer, but you don't take care of the requests which don't have anything after the context path. You could try just adding this line to your jk.conf:
JkMount /clusterjsp loadbalancer
There are other aproaches too, but probably this is the easyest one to test.

Grab SOAP request on localhost

I have the same Service1 service running on localhost and public: http://calculator.gear.host/Service1.svc http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex.
I would like to grab packets for testing purposes using Fiddler. As client acts WcfTestClient.exe application with configuration inside
`WcfTestClient.exe.config` that asks wcf client go through proxy.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy>
<proxy
bypassonlocal="false"
proxyaddress="http://127.0.0.1:8888"
/>
</defaultProxy>
</system.net>
<runtime>
<DisableMSIPeek enabled="true"/>
</runtime>
</configuration>
Everything goes fine with calculator.gear.host, but I cant see packets in Fiddler using localhost or 10.1.2.112 (my ethernet IP).
According to telerik you need to use the machine name rather than localhost or the IP:
http://docs.telerik.com/fiddler/Observe-Traffic/Troubleshooting/NoTrafficToLocalhost

Loadbalancing 3 tomcat 7 instances with mod_jk gives 'Could not find worker'

I'm posting this after checking out several other posts that seem to have the same issue but I can't solve my problem with the help of any of these.
Situation:
-I am using Windows 8 Professional
-I installed 3 tomcat instances on my localhost
-I installed Apache 2.4 with mod_jk to be used as my loadbalancer
What I'm trying to achieve is:
-Goto localhost/APPNAME (which is the Apache 2.4), Apache will now redirect my call to one of the 3 Tomcat 7 instances and give me the requested page.
This is the first time I'm doing this so probably I'm forgetting something somewhere. What I have now is this:
The Tomcat 7 server.xml's look like this:
1st Tomcat has:
<Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
2nd Tomcat has:
<Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
3rd Tomcat has:
<Connector port="8083" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8445" />
<Connector port="8011" protocol="AJP/1.3" redirectPort="8445" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat3">
For the Apache server I added to the httpd.conf:
LoadModule jk_module modules/mod_jk.so
<IfModule jk_module>
Include conf/extra/mod_jk.conf
</IfModule>
The mod_jk.conf looks like this:
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkShmFile logs/jk-runtime-status
JkLogStampFormat "[%b %d %Y - %H:%M:%S] "
JkRequestLogFormat "%w %V %T"
JkMountCopy All
JkMount /* balancer
#JkMount /* tomcat1
#JkMount /* tomcat2
#JkMount /* tomcat3
And finally my workers.properties file looks like this:
worker.tomcat1.type=ajp13
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.lbfactor=1
worker.tomcat2.type=ajp13
worker.tomcat2.port=8010
worker.tomcat2.host=localhost
worker.tomcat2.lbfactor=1
worker.tomcat3.type=ajp13
worker.tomcat3.port=8011
worker.tomcat3.host=localhost
worker.tomcat3.lbfactor=1
#configure the loadbalancer
worker.balancer.type=lb
worker.balancer.balance_workers=tomcat1,tomcat2,tomcat3
worker.balancer.method=B
worker.balancer.sticky_session=True
worker.stat.type=status
Now I have started all mu tomcat instances first, then I start my Apache. It will now give me the following message in the mod_jk.log:
[Dec 12 2014 - 12:23:58] [3180:8452] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:58] [3180:8452] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
[Dec 12 2014 - 12:23:58] [3180:8452] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:58] [3180:8452] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
[Dec 12 2014 - 12:23:58] [9912:8284] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:58] [9912:8284] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
[Dec 12 2014 - 12:23:59] [9912:8284] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:59] [9912:8284] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
Which of course means that I doesn't work. Can anyone please help me and give me an idea what I'm doing wrong?
Okay, I got it to work. It seems that I used an Apache Server which causes the problem.
I was searching a bit more and more specific on this forum and found this post:
httpd AND Tomcat with mod_jk on Port 80 test fails
Thanks to this answer I decided to try a different Apache download too.
From the Apache site I used download to the Apache Haus version of Apache for Windows. I could not get it to work. However, I downloaded another version from the website, copied all my settings, and now it works!

Is it possible to run SSL and non-SSL web applications on same standalone Wildfly?

Is it possible to run SSL and non-SSL web applications on same standalone Wildfly?
I am using Wildfly 8.1.0 (Undertow) and I am having troubles at configuring this scenario...
For example, I know how to configure either HTTP or HTTPS themselves, but whenever I try to run a configuration for both, the HTTP response is redirected to the SSL one... :(
Could somebody please point out what to change for example in the default standalone.xml?
Yes it's possible.
first you need to add bellow code in ApplicationRealm
<server-identities>
<ssl>
<keystore path="server.keystore" relative-to="jboss.server.config.dir" keystore-password="abcd1234" alias="server" key-password="abcd1234"/>
</ssl>
</server-identities>
Then you required to add lisner for both http and https
<server name="default-server">
<http-listener name="default-http" socket-binding="http"/>
<https-listener name="default-https" socket-binding="https" security-realm="ApplicationRealm"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
Now configure the connector for both http and https
<subsystem xmlns="urn:jboss:domain:remoting:2.0">
<endpoint worker="default"/>
<http-connector name="http-remoting-connector" connector-ref="default-http" security-realm="ApplicationRealm"/>
<http-connector name="https-remoting-connector" connector-ref="default-https" security-realm="ApplicationRealm"/>
</subsystem>
But generally people won't keep enable both http and https. They redirect the request from http to https.