Forum

reverse proxy anything but mask

chrisf
7 July 2014, 00:29


Hiawatha version: 9.6
Operating System: Centos 6

Hugo, you had added the anything but ability to the reverse proxy mask (!.pl) however, it has become apparent that other cgi programs desperately need the cgi-wrapper protection that Hiawatha includes.

How to exclude more than .pl files? Say .pl, .cgi, .py? (!.pl|!.cgi|.py) doesn't work.

Any way to do this?
chrisf
7 July 2014, 00:44
This is in reference to https://www.hiawatha-webserver.org/forum/topic/1656

If not possible, could you please make it possible? THANK YOU!
Hugo Leisink
7 July 2014, 08:50
Try !\.(pl|cgi|py) How the anything-but in Hiawatha works is that Hiawatha looks for a !-sign at the beginning and inverses the result of the rest of the expression.

(!.pl|!.cgi|.py) will not work, because it's logically incorrect. Everything is "not A or not B". What you need is a logical-AND, but I'm not aware of an AND operator for this. If it were the &-sign, it would be (!\.pl&!\.cgi&!\.py). Perhaps this page [ocpsoft.org] helps.
chrisf
7 July 2014, 09:30
It worked as you explained, thank you. Perl is executing without problem. However, python always throws a 500 internal server error? Is there any special requirements to run python scripts?
chrisf
7 July 2014, 09:33
CGIhandler = /usr/bin/perl:pl
CGIhandler = /usr/bin/perl:cgi
CGIhandler = /usr/bin/python:py
CGIhandler = /usr/bin/ruby:rb
CGIhandler = /usr/bin/ssi-cgi:shtml

This is my cgi handlers and i have execute cgi directive set to yes in the virtual host.
Hugo Leisink
7 July 2014, 09:34
Not that I'm aware of. What does the error logfile say? If Hiawatha generated the 500, the error logfile should contain the reason. If not, it's very likely that the Python script generated the error. In that case, the execution of the script by Hiawatha was done correctly.
chrisf
7 July 2014, 09:51
107.178.35.20|Mon 07 Jul 2014 03:18:52 -0400|/home/test.py|CGI only printed a HTTP header, no content

My script is
#!/usr/bin/python

print "Hello, Python!";

Which works from the cli.
Hugo Leisink
7 July 2014, 09:53
Your script doesn't follow the CGI standard. For every CGI script, follow these rules:
1: Print at least a Content-Type header.
2: Every header line should end with CRLF.
3: Close the header by printing an empty line.

Try this:
#!/usr/bin/python

print "Content-Type: text/plain\r\n\r\n";
print "Hello, Python!";
chrisf
7 July 2014, 10:02
That is why I am a php guy! yup, all worked. I want to thank you very much for your help.
Hugo Leisink
7 July 2014, 10:03
You're welcome. I know, PHP makes it all very easy. However, it's never a bad thing to know what is done automatically. Knowledge is power!
This topic has been closed.