Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Can't POST with PHP to webapp in Apache/Tomcat, 403 Forbidden error


Ok, I've got a config problem that has stymied me. The crazy thing is I had the same setup, just moved to a new server machine.

There is an internal database and web application in Java running on Tomcat through Apache httpd. Then there is the web site on another server which uses PHP. The web site connects to this internal stuff in a couple ways, one of which is just basically POSTing data to a JSP which does the work and returns some XML to the web server for output.

Now I installed everything fresh on the new server and got everything working except that I cannot get PHP to post to JSPs like I did before. To debug, I created a PHP file that only did the POST to narrow things down. After debugging, I found I'm getting a 403 Forbidden error - You don't have permission to access /web_connect/web_submit_test.jsp on this server. In the Apache error log is
Code:

[Mon Aug 02 18:41:38 2010] [error] [client xxxxxxxxx] client denied by server configuration: web_submit_test.jsp
It's strange because when I put the URL directly into my browser, it works fine - it submits a little data, gets back a little xml, that all works. That means it's nothing related to Tomcat. But it doesn't work through my PHP code - which had been working just fine for months on the other server.

The Forbidden error makes me check my Apache httpd.conf and httpd-ssl.conf files. I didn't see any difference in allowing or denying. I'm actually not denying anything. Here is the part of httpd-ssl.conf in question:

Code:

<VirtualHost _default_:443>

# General setup for the virtual host
DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs"
ServerName xxxxx.xxxxxxx.com:443
ServerAdmin xxxxxxxx@xxxxxxx.com
ErrorLog "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/error.log"
TransferLog "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/access.log"

<Location /web_connect>
Order allow,deny
Allow from all
</Location>
JkMount /web_connect worker1
JkMount /web_connect/* worker1
...
</VirtualHost>

Note the document root isn't used at all. The web_connect is a Tomcat webapp.

The PHP file I'm using to test is:

Code:

<?php
$fp = fsockopen("ssl://xxxx.xxxxxx.com", 443, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "POST /web_connect/web_submit_test.jsp?input1=blahblah1&input2=blahblah2 HTTP/1.1\r\n";
$out .= "Host: xxxxxx.xxxxxxxxx.com\r\n";
$out .= "Connection: Close\r\n\r\n";//extra line required here
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>

I'm pulling my hair out here so any help is appreciated!
View Original Thread
Comments
0
Be the first to comment

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect
avatar
Tags: server, file, work, php, code
svn commit: r981441 - in /tomcat/trunk: java/org/apache/tomcat/util/http/fileupload/ test/webapp-3.0/WEB-INF/tags/ test/webapp-3.0/bug45nnn/
Aug 2, 2010
Author: rjung Date: Mon Aug 2 10:00:40 2010 New Revision: 981441 URL: http://svn.apache.org/viewvc?rev=981441&view=rev Log: Fix svn properties: - java/org/apache/tomcat/util/http/fileupload/InvalidFileNameException.j ava Removed mime-type…

Support multiple apache contexts via one tomcat webapp context
Jun 15, 2010
I am trying to setup Apache with JkMount to tomcat to dynamically handle different contexts in Apache, but always use the same context in Tomcat. e.g. http://apachefrontenddomain.com.au/a/customer-1.com -> jk ajp to ->…

svn commit: r948644 - in /tomcat/trunk/test: org/apache/el/TestELInJsp.java webapp-3.0/WEB-INF/tags/echo-deferred.tag webapp-3.0/el-method.jsp
May 26, 2010
Author: markt Date: Thu May 27 00:43:54 2010 New Revision: 948644 URL: http://svn.apache.org/viewvc?rev=948644&view=rev Log: Extend to test deferred expressions. Need to use request scope attributes since page scope ones won't be visible to…

svn commit: r966750 - in /tomcat/tc6.0.x/trunk: ./ STATUS.txt java/org/apache/catalina/loader/WebappClassLoader.java webapps/docs/changelog.xml
Jul 22, 2010
Author: markt Date: Thu Jul 22 17:02:32 2010 New Revision: 966750 URL: http://svn.apache.org/viewvc?rev=966750&view=rev Log: Return a copy of the URL being used from the webapp class loader, not the original. Modified: …

svn commit: r951909 - in /tomcat/trunk: java/org/apache/catalina/session/StandardSession.java webapps/docs/config/systemprops.xml
Jun 6, 2010
Author: markt Date: Sun Jun 6 17:36:34 2010 New Revision: 951909 URL: http://svn.apache.org/viewvc?rev=951909&view=rev Log: Use STRICT_SERVLET_COMPLIANCE to override the default for ACTIVITY_CHECK to align behaviour with other system…

svn commit: r982877 - in /tomcat/trunk: java/org/apache/catalina/ha/session/DeltaManager.java webapps/docs/changelog.xml
Aug 6, 2010
Author: kfujino Date: Fri Aug 6 05:56:21 2010 New Revision: 982877 URL: http://svn.apache.org/viewvc?rev=982877&view=rev Log: Add Null check when CHANGE_SESSION_ID message received. Modified: …

svn commit: r993042 - in /tomcat/trunk: java/org/apache/catalina/ha/session/DeltaManager.java webapps/docs/changelog.xml
Sep 6, 2010
Author: markt Date: Mon Sep 6 14:39:48 2010 New Revision: 993042 URL: http://svn.apache.org/viewvc?rev=993042&view=rev Log: Avoid NPE when a parallel request invalidates the current session Modified: …

svn commit: r951923 - in /tomcat/trunk: java/org/apache/catalina/core/ApplicationContext.java webapps/docs/config/systemprops.xml
Jun 6, 2010
Author: markt Date: Sun Jun 6 18:39:33 2010 New Revision: 951923 URL: http://svn.apache.org/viewvc?rev=951923&view=rev Log: Part of refactoring STRICT_SERVLET_COMPLIANCE so it just changes defaults New GET_RESOURCE_REQUIRE_SLASH property …

svn commit: r987995 - in /tomcat/trunk: java/org/apache/catalina/ha/session/DeltaSession.java webapps/docs/changelog.xml
Aug 22, 2010
Author: kfujino Date: Mon Aug 23 04:57:49 2010 New Revision: 987995 URL: http://svn.apache.org/viewvc?rev=987995&view=rev Log: Add support for LAST_ACCESS_AT_START system property to DeltaSession. Modified: …

svn commit: r951985 - in /tomcat/trunk: java/org/apache/catalina/session/StandardSession.java webapps/docs/config/systemprops.xml
Jun 6, 2010
Author: markt Date: Sun Jun 6 21:24:09 2010 New Revision: 951985 URL: http://svn.apache.org/viewvc?rev=951985&view=rev Log: Final part of refactoring STRICT_SERVLET_COMPLIANCE so it just changes defaults New property LAST_ACCESS_AT_START …