apache and IP oddities - apache

I installed Apache 2.4 in order to publish a java (Struts2) application using Tomcat 8 as AS.
For a while it worked out well then something happened "strange" (to put it mildly).
By typing "http://localhost/appName" all continues to work out wonderfully.
Typing "http://publicIP/AppName " it opens pop up asking for a password to access the network printer!
The PC address on which they reside, Servers and Application, is 192.168.0.104, the one of the printer is just 193.168.0.103, exactly the previous by the point of view of the router (working in DHCP mode).
But (I may be *** but not to this extent) to the PC I manually set 104 as the fixed IP (which is still set - and anyway, when I check the Client List on the monitor of the router, I find right 104 as IP assigned to the PC).
No one has changed the settings to httpd.conf (ServerName is always 104), let alone the various mod_jk.conf or workers.properties or server.xml of Tomcat (so much so that, as I said, typing in the browser the local address all still works)!
...what could possibly have happened?

It sounds like your firewall is port forwarding port 80 to the private IP of the printer, rather than the apache server. The fact that you're getting the printer means the problem is not related to the apache or tomcat configuration.

Something new happened so I think Apache or Tomcat conf is related.
I restarted the router: at first, typing in the browser "http:// publicIP/appName", all was working, after several minutes, typing the app address, it asks me if i wanna download a (unspecified) file and accessing directly to Apache (typing "http:// publicIP") it answers "It works"!
Accessing to "http:// localhost/appName" anytime all works fine!
I restarted the router for a second time: accessing to "http:// publicIP/appName", error message "File not found" and typing "http:// publicIP", it asks me the pw to access to an IPcam! I thinked: "It's trivial! if it aims for the IPcam... it can't find my app!" ("http:// localhost/appName" ever all fine, of course!)
But no: i restarted for a third! Maybe all ok for several minutes and after: "http://publicIP/appName" returns still a "File not found" message but "http://publicIP" tells me "It works!"...!!!
Maybe the connector (or the connector configuration) bears some responsibility for this whole mess?
If my suspicious can have some substance I add the code.
I've a basic manual configuration:
at the end of httpd.conf
include "C:/Program Files/apache-tomcat-8.0.23/conf/jk/mod_jk.conf"
in mod_jk.conf:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile "C:/Program Files/apache-tomcat-8.0.23/conf/jk/workers.properties"
(JkLogFile, JkLogLevel, JkLogStampFormat, JkOptions, JkRequestLogFormat are also set)
JkMount /appName ajp13
JkMount /appName/* ajp13
in workers.properties:
worker.list=ajp13
worker.ajp13.type=ajp13
worker.ajp13.host=localhost
worker.ajp13.port=10009
worker.ajp13.lbfactor=50
worker.ajp13.cachesize=10
worker.ajp13.cache_timeout=600
worker.ajp13.socket_keepalive=1
worker.ajp13.socket_timeout=300
and finally, in server.xml:
Connector port="10009" protocol="AJP/1.3" redirectPort="8443" enableLookups="false" /
thank you!
PS - I have another suspicious too: the IPcam remote monitor works on port 80... there may be some relationship? (but that don't explain the download request...)

Related

Mod_jk and Tomcat stuck at Sending Reply

Currently, the server at work is underperforming and the way it's set up is not ideal either. For this reason I'm trying to find a new way to do things that will hopefully help with both, performance and deployment.
The approach I decided for is to have tomcat instances for our webapps (currently there are two, so it'd be an instance per webapp) and use Apache as a "front". I'm not experienced in this, so It's normal I'm having issues here and there, but so far I've manage to get this going.
What I expect is to redirect from mysite.com index page to either mysite.com/service1 or mysite.com/service2. Service1 was setup in out test server at port 8080 and service2 at 8081. I installed Apache2 and mod_jk yesterday and set up apache with the contents of mysite.com. Today I started the configurations, that ended up as follow:
workers.properties
worker.list=s1
worker.s1.type=ajp13
worker.s1.port=8009
#host is localhost by default according to the documentation
jk.load
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
JkMount /service1/* s1
Service1's server.xml connector (The rest is all default)
<Connector protocol="AJP/1.3" port="8009" redirectPort="8443" />
I had more, but because of the errors, I took a step back and tried with only one tomcat for now. I will add the second tomcat and a loadbalancer.
Ok, so what's going on?
I can access the server and the index page of our system with no problem. The problem is when I try to redirect to service1. It just loads without response, but if I try to access service1 directly by port 8080, it works properly (I tired commenting out this connector. No luck).
Looking at server-status, I see the request stuck at w/sending reply, and in mod_jk.log I see that the worker properly matches the request. So while my configurations seem to be right, there is something in between happening. I don't really know if it's something with Apache, Tomcat or Mod_jk. I also tried to follow several guides of how to do this, but all of them got me to 404s. Looking around here and ServerFault didn't shed much light unfortunately so I'm the one asking now.
Am I missing something? Should I just use another approach? I'm very new at this and I'm at loss right now. The configuration and the logs show that nothing is really wrong (at first glance, at least...) so I'm entirely sure if my case scneario is even posible with mod_jk... HOnestly to run it back and try with proxy is very tempting at this point, but if I am, I'd rather know where Im wrong.
Additional info: Running on Ubuntu Server 18.04, lastest apache2 and mod_jk avaliable from apt (as of Apr 14), java 1.8 and Tomcat 8.5.64.
There was a change in Tomcat last year (from version 8.5.51 and version 9.0.31), which introduced a secretRequired attribute to the AJP connector with a default of true (cf. documentation). Hence you can either:
add a shared secret between the AJP connector and mod_jk
or add secretRequired="false" to the AJP connector:
<Connector protocol="AJP/1.3" port="8009" secretRequired="false" redirectPort="8443" />
Remark: AJP is a very old protocol and rarely used. Since your installation is pretty new, you might consider using directly HTTP (cf. this talk).

XAMPP, Apache and IIS on the same machine

Im trying to run XAMPP on the same machine as IIS but I cant make apache work. I changed the ports to 8080 and 4333 but I still cant run it. If I stop IIS service, apache starts normally. Is there any way to make it work here?
thanks.
These should work together as long as not colliding on ports, I currently run both at same time myself, and have run into same pain you have. XAMPP Apache doesn't say which port, it just don't start.
I commented out all "443 Listen" & "NameVirtualHost *:443" entries - (with #) , and changed xampp sites to a non iis port (my case 86) in apache\conf\httpd.conf, but also be sure you check the config(s) in E:\xampp\apache\conf\extra. xampp has "extra" configs there.
Be sure to check that D:\xampp\apache\conf\extra\httpd-vhosts.conf is not set to use\listen on 443.
updating answer here a bit...
Actually you may just need to comment the Listen 443 line, (change to #Listen 443, or change to 4333 or what ever) in D:\xampp\apache\conf\extra\httpd-ssl.conf at about line 36 or so. The section in that file with ..
<VirtualHost default:443>
defined can just sit there unused if you dont need it then, so no need to comment that section out for now.
Sorry, that was actually my issue - I did this so long ago I forgot. Apache files are not set up the same way.
...
Basically there is a port conflict you need to clear up. also be sure you dont leave "copied" or "backed" up conf files with the .conf extension in the conf folders - sometimes those get grabbed and used. Good luck on your dup port Hunt.
... putting my comments here because they may be getting buried...
ok, just try commenting out any listen settings other than the one you need (8081) in the config files instead (httpd.conf, extra/httpd-ssl.conf & extra/httpd-vhosts.conf). You may be bumping into your own listen settings elsewhere in your conf files. one time i mistakenly set 443 in main httpd.conf and in ssl.conf. besides you might not need 443 at all anyway. the answer is in your conf files somewhere. perhaps a file contents search for "listen" in the /conf/ folder might help.
also you may want to check out the "netstat" button from xampp panel - it should tell you a bit more about what is using what ports, that sometimes gives good clues
And if you did not know or are new to xampp/apache VERY IMPORTANT
REMEMBER TO RESTART APACHE AFTER ANY CONF CHANGE !

WAMP virtual host displays in Chrome, but Internet Explorer says "Page can't be displayed"

I installed WAMP and followed this guide to set up virtual hosts. In both Google Chrome and Internet Explorer, http://localhost gets me to "WAMPSERVER homepage" with my virtual host listed under "Your Projects."
Clicking that link to http://mysite.local in Chome brings me to my site as expected.
Clicking that link in Internet Explorer displays the following message instead.
This page can’t be displayed
•Make sure the web address http://mysite.local is correct.
•Look for the page with your search engine.
•Refresh the page in a few minutes.
Since I can see the WAMPSERVER homepage as expected in both browsers, I don't think there's a problem with my WAMP installation. Since my virtual host is working in Chrome, I think it must be configured properly in Apache and in my Windows hosts file.
I just don't understand why Internet Explorer isn't working with my virtual host like I expect it to, and the "Page can't be displayed" message doesn't give me anything helpful to work with.
Does anyone have any suggestions for me? I'd greatly appreciate any pointers or links to other guides I can try. Thanks in advance for any replies!
There's several reasons WAMP/MAMP may not work on a local environment, I'll try to list a few reasons here:
Which httpd.conf?
There are sometimes multiple httpd.conf files that can cause things to go a little bit funny. MAMP/WAMP usually tend to keep all their configuration files within a conf/ directory however, that doesn't mean to say some other httpd.conf file is being used...
You can also run this command on Linux based systems to see which one is being used:
apache2ctl -V | grep SERVER_CONFIG_FILE
vhosts definitions not included in httpd.conf
In the httpd.conf file, there's a line to include the vhosts definitions file, it should be uncommented:
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf // remove the #
Incorrect vhosts definitions
Vhosts need to be defined as follows:
<VirtualHost *>
DocumentRoot "C:/path/to/your/local/site"
ServerName mydomain.local
</VirtualHost>
Hosts file
On OS X/Linux systems this can be found at etc/hosts. Edit that to reflect below (note, you'll need to be root)
127.0.0.1 mysite.local
On windows systems, it can be found in %SystemRoot%\System32\drivers\etc\hosts.
Browser caches
Browser caches always cause an issue with local servers/development. It's worth working with incognito mode on, or deleting all browser caches each and every time you open it up. There's a few plugins available for most browsers that should help too.
Other points to note
Whenever you edit anything to do with httpd.conf, vhosts, hosts file - WAMP/MAMP/Apache needs to be restarted. It's a good idea to shut the server down before doing the changes.
You mentioned that there was a hardcoded link in one/some of your files. It's generally regarded as bad practise to do that for this exact reason. Your code is less portable and can 'break' on other systems. I'd suggest using PHP's __FILE__ or similar to achieve what you want.
Alternatively you could set up local configuration files for your app that are only included when they're present. Have a look at this for a good example of such a set up.
Log everything. Check the logs regularly too.

Load Balancing and Clustering in Liferay- css not loading

I am trying to Implement clustering in liferay 6.2 on my local system using sticky sessions.
I followed below steps to configure this.
1 install Apache Webserver and made following changes in httpd.conf
Added below code snippet at the end of file.
<Proxy balancer://clusterdemo>
BalancerMember ajp://localhost:8009/ route=INT1 smax=15 max=50 loadfactor=20
BalancerMember ajp://localhost:8010/ route=INT2 smax=15 max=50 loadfactor=20
</Proxy>
<Location / >
ProxyPass balancer://clusterdemo/ stickysession=JSESSIONID
</Location>
and uncommented below lines
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule status_module modules/mod_status.so
2 Extracted two copies of Liferay 6.2 bundle and changed the port nos accordingly
3 Changed jvmRoute in server.xml file of both Liferay tomcat bundle.
First Instance
<Engine name="Catalina" defaultHost="localhost" jvmRoute="INT1">
Second Instance
<Engine name="Catalina" defaultHost="localhost" jvmRoute="INT2 ">
4 Added below properties in portal-ext.properties file of both Liferay instance and configured same database for both instances.
cluster.link.enabled=true
cluster.link.autodetect.address=localhost:3306
5 Restarted Apache Webserver and both Liferay instance
If i hit http://127.0.0.1/web/guest/welcome url in browser i can see login page and by entering username and password i am able to login.
Problem
Now my problem is css files are not getting loaded properly as shown in below image.But with classic theme its working fine.
I think its able to load css file from Liferayhome\tomcat-7.0.42\webapps\ROOT\html\themes\classic but not from Liferayhome\tomcat-7.0.42\webapps\welcome-theme any reason??/.
Firbug Screenshot
Could you please help me help me in this?
**Update:**I further checked few things in browser and looking at cookie i can verify its transferring control to both instances.
Cookie:COOKIE_SUPPORT=true; JSESSIONID=48705C436A9BE3D054577705EA41FA77.INT1; GUEST_LANGUAGE_ID=en_US
Cookie:COOKIE_SUPPORT=true; JSESSIONID=C04FBBD76B10422D292827B301320DC4.INT2; GUEST_LANGUAGE_ID=en_US
Thanks in Advance
You're missing several other steps in correct Liferay clustering as well. From the top of my head,
Document Library
Search Index
are obvious missing steps. Please go through the Liferay clustering documentation and note that this is only part of the story: In Liferay's System Administration Training we'll take almost a full day to discuss all of the different clustering options. That doesn't mean that clustering takes that long - it's just that there is no single correct cluster configuration, but it all depends on the available infrastructure and expected load and use cases for your portal.
As of the missing CSS files - please monitor what replies exactly you get back from Apache/Liferay - e.g. use Firebug or similar tools to check if you get 404, 500 or others back, and what the error message is.
As of configuring sticky sessions, I'm typically configuring tomcat to indicate the server name (look up jvmRoute for server.xml) so that it automatically adds its name to the sessionid and Apache has a chance to know which tomcat created the session.
After your comments, more things to check:
Identify which server you're balanced to. Then access the missing resources through http - e.g. port 8080 or 8081 (or whatever that server has configured)
Check if this only happens when INT1 goes down but not when INT2 does (or vice versa)
Check if this happens when you're balanced to another server than initially (e.g. you're on INT1, take down INT1, get balanced to INT2 -> Problem? You're on INT1, take down INT2, stay on INT1 -> Problem?)
Make sure the AJP forwards are correct - you use localhost in your question. It's quite untypical to have two machines on the same server. If you changed this for the question, make extra extra extra sure that the hostnames are valid and do not contain typos. - and they're routable. Try nmap from the Apache host to the appservers to make sure the ports are reachable and no firewall steps in between Apache and your appserver
While you do all of this, keep your eyes open and don't blindly follow this advice: There's so much to pay attention to that it's impossible to list everything in this answer.
Also, this gets closer to system administration rather than programming and might be better suited for serverfault.com.
I don't know much about Liferay, but I have dabbled with Tomcat.
I'd suggest you check how ROOT and welcome-theme are configured in server.xml (and/or any context XML files).

iis and apache combination on real server for 403

We have a win2003 server that run both IIS 7 and apache (using wamp server 2.2).
We put on both server a page named test.html that show us a message that say "You are on IIS page" and "You are on WAMP page" to show us if everything is working correctly.
Both running real great locally. IIS is listening on port 80 and apache on port 8082. The problems come remotly. Both services are running and wamp is fully online (green icon + "put online" option activate).
Locally, on the server, doing http://localhost/test.html and http://localhost:8082/test.html show the correct pages. If we replace localhost by real IP address (for example purpose, let say http://10.2.5.16/test.html and http://10.2.5.16:8082/test.html), still work. (not actual address but address used for real is the same used by dns web service)
Remotly, from any other PC, doing http://10.2.5.16/test.html and http://10.2.5.16:8082/test.html, the first give us the website normally, the second give us a HTTP 403 FORBIDEN (tried using both htaccess and windows permission, still have 403). The same way, using http://www.ourdomain.com/test.html and http://www.ourdomain.com:8082/test.html give us the exact same result (first ok, second 403)
Is it possible to make it work correctly?
Thanks in advance.
edit: Just to add to the solution :
the firewall was blocking me, add the wamp on this port allowed
in my configuration, i had in my directory statement Require local, which needed to be set to Require all granted
for the rest, the solution was pretty it.
Thanks again.
The fact that you can get to the sites locally tells me both servers are setup correctly and listening on respective ports.
Upon further questions, the OP indicated that the Servername Directive, is pointing to localhost and it should be changed as.
ServerName localhost:8082
To
ServerName example.com:8082 # or add "ServerAlias example.com:8082" to your existing.
Where as example.com is your site DNS. Then in your [System32\drivers\etc\hosts] point that DNS to the ip of your Remote host.
403 is happening because the request from the remote is not matched against any Servername or ServerAlias and it falls to the default handler which normally has stricket permissions. If you look closely in logs(/logs/apache/access.log), there should be something about "access denied by server configuration /somelocation like your default DocRoot"
If you make request for http://example.com and you have correct ip in your hostfile, you can trace what happens to that request in the remote host and where it ends up(firewalls, Apache etc). Apache is good at logging and you just need to find relevant log entries!