PSGI application with Apache2 using Plack::Handler::Apache2 results in 'not found' - perl

first time poster, long time lurker here.
Im using a tiny PSGI application in plackup, but id like to switch to Apache2 for subdomains. I run the application with 'plackup /home/ath88/work/kolle/script/dir.psgi -port 80'. It runs perfectly on plackup. The application is quite simple and can be found at https://github.com/ath88/Kolletilmelding/blob/master/script/dir.psgi
But, i would like to run Apache2 instead of plackup for obvious reasons. For this i want to use Plack::Handler::Apache2. My VirtualHost looks as follows:
<VirtualHost *:80>
ServerName aths.dk
ServerAdmin asbjoern#gmail.com
<Location />
SetHandler perl-script
PerlResponseHandler Plack::Handler::Apache2
PerlSetVar psgi_app /home/ath88/work/kolle/script/dir.psgi
</Location>
</VirtualHost>
Apache2 restarts fine. But when i attempt to visit aths.dk i mere get a 404 not found. The directory for the application is correct, since it results in a 500 Internal Error. Looking in the apache2/error.log i get this: [Irrelevant, see edit]
[Wed Oct 05 21:32:16 2011] [notice] caught SIGTERM, shutting down
[Wed Oct 05 21:32:17 2011] [notice] Apache/2.2.12 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
This happens every time i restart Apache2.
I have spent 4 hours trying to debug this. I am totally mindboggled.
Edit: Turns out the SIGTERM was from stopping Apache2 for restarting. It doesn't happen when i start it. Silly me.

Maybe your setup will benefit from a reverse HTTP proxy setup.
You can start your Plack application manually, and you can bind it to 127.0.0.1:9001 instead of 127.0.0.1:80, in which case you need a privileged user ( TCP port below 1024 ).
Then a reverse HTTP proxy config that should work could be like this one:
<VirtualHost *:80>
ServerName aths.dk
ServerAdmin asbjoern#gmail.com
ErrorLog /var/log/apache2/aths.dk-error.log
TransferLog /var/log/apache2/aths.dk.log
DocumentRoot /var/www/aths.dk
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:9001/
ProxyPassReverse / http://127.0.0.1:9001/
</VirtualHost>

Related

Apache Reverse Proxy produces too many redirects

I have configured apache to redirect HTTPS reqests to the local running application server PUMA. PUMA is part of the Ruby on Rails framework.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
Puma Server is listening on http://localhost:3000/
When I access this apache web site from a browser I get: Too many redirections.
And idea?
I had the same issue. Try to add after your Proxy:
RequestHeader set X-Forwarded-Proto https to your ...ssl.conf which is in sites-available folder.
I had same issue, I was trying to setup a SSL termination reverse proxy with apache. I followed this article.
Using 0.0.0.0 instead of localhost worked for me.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName exemple.com
SSLCertificateFile /path/fullchain.pem
SSLCertificateKeyFile /path/privkey.pem
ProxyPass / http://0.0.0.0:80/
ProxyPassReverse / http://0.0.0.0:80/
</VirtualHost>
</IfModule>

weblogic & OHS: How forward one url to a different server

I have an environment with Oracle WebLogic and OHS running.
In the mod_wl_ohs.conf I have following (beside config for other applications)
<Location /application1>
SetHandler weblogic-handler
WLLogFile /opt/logs/ application1.log
Debug OFF
WebLogicHost 127.0.0.1
WebLogicPort 23666
</Location>
This works fine the and the server listening to 23666 with the actual application1 application is handling the requests like “http://example.com/application1/*” .
Now I would like to redirect all requests for specific URL pattern to a different domain (not necessary on the same server), but continuing handling all requests others.
Redirect: http://example.com/application1/MagicKeyword/*
continue on: http://example.com/application1/NotTheKeyword* or http://example.com/application1/AlsoNotKeyword/*
What is the right approach for that?
I played around with some mod_rewrite rules, it seems they don’t take affect or break everything (in httpd.conf). I was also reading that we should not use mod_rewrite rules inside of location tag (can't find the reference now).
What else can I do?
Edit: So finally I found my error (somehow wrong syntax which not prevented the server from starting (like usual).
So I could:
in httpd.conf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "(.*)/application1/MagicKeyword/(.*)$" "https://www.example.org" [NC,L,R=301]
</IfModule>
or in the Location tag add:
RewriteEngine On
RewriteRule "(.*)/MagicKeyword/(.*)$" "https://www.example.org" [NC,L,R=301]
Why should I prefer one over the other?
Is there anything to concern about?
Two other options you can consider. You can use the order of location tags:
<Location /application1/MagicKeyword>
WebLogicHost otherhost
</Location>
<Location /application1>
WebLogicHost 127.0.0.1
</Location>
You can tell WebLogic to exclude a path (see https://docs.oracle.com/middleware/1212/webtier/PLGWL/plugin_params.htm#PLGWL473):
<Location /application1>
WebLogicHost 127.0.0.1
WLExcludePathOrMimeType /application1/MagicKeyword
</Location>
<Location /application1>
WebLogicHost otherhost
</Location>

Tuleap unable to upload file

I have installed tuleap on centos 6.7 and having trouble to properly configure tuleap in following scenario. I have gone though the documentation and mailing list archives but didn't find the solution.
have ubuntu server with static ip address XXX.XXX.XXX.XXX accessible from outside
on the above server I have installed virtualbox and installed centos 6.7 + tuleap (local ip address YYY.YYY.YYY.YYY which is accessible from above ubuntu server only)
I have setup ProxyPass and ProxyPassReverse on ubuntu server which works fine:
ProxyPass / https://YYY.YYY.YYY.YYY/
ProxyPassReverse / https://YYY.YYY.YYY.YYY/
All features are working fine except when I try to upload the files. I see two issues:
When I try to upload file in "Document", I see below messages:
“Permissions successfully updated.
Document successfully created.
Error while creating initial version.”
But when I check apache error log I see that Docman_FileStorage.class.php tries to create file in the root directory i.e. something like /testproject/3/6/36/1 and hence get permission denied error. I am checking local.inc file but wondering where I have to set base path for storing documents?
I see another issue while attaching file to wiki pages. When I hit “Upload” button, the url mysite.domain.com get transferred to YYY.YYY.YYY.YYY ip address! BUT as the YYY.YYY.YYY.YYY is virtual machine ip address and not accessible from outside, I get page not found error. Could you tell me what might be missing? My proxy-pass apache setting looks like:
<VirtualHost *:80>
ServerName mysite.domain.com
ServerAlias *.mysite.domain.com
ProxyRequests off
ProxyPreserveHost off
SSLProxyEngine On
SSLProxyVerify none
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / https://YYY.YYY.YYY.YYY/
ProxyPassReverse / https://YYY.YYY.YYY.YYY/
</VirtualHost>
# Listen 443
<VirtualHost mysite.domain.com:443>
ServerName mysite.domain.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine On
SSLProxyVerify none
SSLProxyEngine On
SSLCertificateFile /etc/apache2/ssl/my.crt
SSLCertificateKeyFile /etc/apache2/ssl/my.key
ProxyRequests off
ProxyPreserveHost off
ProxyPass / https://YYY.YYY.YYY.YYY/
ProxyPassReverse / https://YYY.YYY.YYY.YYY/
</VirtualHost>
Any help to solve above issues will be appreciated.
Thanks!
I would suggest to look at selinux first.
Please try to run setenforce 0 on the centos box and try to create documents again. If that solve the problem, set selinux to permissive.

Mapping a subdomain to a Servlet context using Apache 2.x and Tomcat 6.x

I have installed Archiva on my machine under Tomcat 6.x at http://dev.mycompany.com:8080/archiva and can access the application and everything, but I want to access it from the subdomain archiva.mycompany.com.
I have Apache 2.x running on port 80 and using Virtual Hosts and mod_proxy to route from other subdomains to the other various services I am running on this machine.
I now want to create a subdomain archiva.dev.mycompany.com and point that to dev.mycompany.com:8080/archiva.
I can't figure out what I need to put in my ProxyPass and ProxyPassReverse to make this work like I want it to.
I tried the following and all it does is add /archiva to the URL over and over again.
<VirtualHost *:80>
ServerAdmin me#mycompany.com
ServerName archiva.dev.mycompany.com
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://dev.mycompany.com:8080/archiva
ProxyPassReverse / http://dev.mycompany.com:8080/archiva
</VirtualHost>
and I get this error message
HTTP Status 404 - /archivaarchiva/
type Status report
message /archivaarchiva/
description The requested resource (/archivaarchiva/) is not available.
I went and dug through everything I could find on Google once again and tried the following:
ProxyPass / ajp://dev.mycompany.com:8080/archiva/
ProxyPassReverse / http://dev.mycompany.com:8080/archiva/
now I just get a 404 error code from the Winstone Servlet Engine, I know I am getting close.
Can anyone tell me what magic incantation I need to make this behave as I desire?
I had the exact same problem.
What has to be done :
reconfigure archiva to have archiva
running on / instead of /archiva/
configure reverse proxy in the
apache2 configuration.
So now i have "http://repo.[domain]/" for main archiva URL, pointing on "http://[domain]:[port]/"
Here's my current Apache2 configuration :
ProxyRequests Off
ProxyPreserveHost On
<VirtualHost [ip]>
ServerName repo.[domain]
ProxyPass / http://[ip]:8082/
ProxyPassReverse / http://[ip]:8082/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
And about the conf/jetty.xml configuration :
-remove this :
<!--
<Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications">
<Arg><Ref id="Contexts"/></Arg>
<Arg>./apps</Arg>
<Arg>org/mortbay/jetty/webapp/webdefault.xml</Arg>
<Arg><Ref id="plusConfig"/></Arg>
<Arg type="boolean">True</Arg>
<Arg type="boolean">False</Arg>
</Call>
-->
+add this instead:
<New class="org.mortbay.jetty.webapp.WebAppContext">
<Arg><Ref id="Contexts"/></Arg>
<Arg>./apps/archiva</Arg>
<Arg>/</Arg>
<Set name="configurationClasses"><Ref id="plusConfig"/></Set>
</New>
The reason you are getting:
HTTP Status 404 - /archivaarchiva/
is because you didn't end your ProxyPass last path with a / but you did ended the first path with one.
ProxyPass / http://dev.mycompany.com:8080/archiva
both ProxyPass and ProxyPassReverse should end with /
Rewrite to (taking note of the ending /):
ProxyPass / http://dev.mycompany.com:8080/archiva/
see: http:// httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
If the first argument ends with a trailing /, the second argument should also end with a trailing / and vice versa. Otherwise the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.

zend framework problem

i want to install zend framework,i set my virtual hosts as the following :
Windows host setup :
127.0.0.6 nolanalg
xampp virtual host setup (httpd-vhosts.conf) :
NameVirtualHost 127.0.0.6
<VirtualHost 127.0.0.6>
DocumentRoot "C:/xampp/htdocs/nolanalg/public/"
ServerName nolanalg
</VirtualHost>
but i got an error!
it shows me this :
Server error! The server encountered
an internal error and was unable to
complete your request. Either the
server is overloaded or there was an
error in a CGI script. If you think
this is a server error, please contact
the webmaster.
Error 500 nolan
06/10/10 16:23:41 Apache/2.2.4 (Win32)
DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8d
mod_autoindex_color PHP/5.2.1
my OS is windows 7,i had uninstall my antivirus,and turned off my windows firewall.
what is the problem?
i think you create your virtual host same following code in httpd-vhosts.conf
NameVirtualHost localhost:80
<VirtualHost mytest:80>
<Directory "C:/xampp/htdocs/mytest/public">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DocumentRoot "C:/xampp/htdocs/mytest/public"
ServerName mytest
ServerAlias mytest
</VirtualHost>
so in c:\windows\system32\drivers\etc open host file
and add foloowing line
127.0.0.1 mytest
instead 127.0.0.1 enter your IP