Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have apache running on port 7979 to talk with a device that sends data to webserver and later will run php scripts to process and send reply xml.

The problem now is that it sends data like

POST HTTP/1.1
Content-Type:text/xml
Content-Length:369
Followed by XML

When apache sees this it gives a 400 error. Since the device cannot be changed is there any way to accept the full data sent from the device and write to some log? Currently apache simply keeps sending 400 errors back. If there was a way to log the entire xml or create some custom handler for 400 error then the xml could be read by a php script.

Looking forward to solutions.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If apache think the request is incorrect, you couldn't use Apache. Maybe check on (x)inetd/nc server with a PHP script launched. Your script will receive all the connection and use it as it want.

share|improve this answer
    
thanks, xinetd with php might work. let me try that thanks. Any pointer on how to get started on centos with xinetd and php? Searching the internets on howto now. –  ServerDown Apr 21 '10 at 8:09
1  
Look at xinetd : you just need to open a port and when a connection arrive, the PHP software will be launched. I think you should read stdin in PHP to see the datas. Sorry, I don't have any Howto. –  Dom Apr 21 '10 at 14:57
1  
Here is a test : In inetd.conf : 88 stream tcp nowait root /home/user/testInet.php And testInet.php #!/usr/bin/php <?php $fp = fopen ("php://stdin", "r"); $line = fgets ($fp); echo "TEST\n"; exit; ?> If you connect with telnet localhost 88, send a text (like your client), and you will receive the text "TEST" Of course, it is just a proof of concept, there is no security –  Dom Apr 21 '10 at 15:07
    
I managed to get this working did some PHP socket programming without inetd / nc server Just plain PHP and it works great. Just followed functionblog.com/?p=67=1 –  ServerDown Apr 21 '10 at 16:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.