Hello,

I've upgraded my 5.4 server to 5.5 and then 5.6 and have switched
from nginx to httpd. This is all excellent.

I wanted to share how I made httpd work for me. I host a simple
static site, but also need '301 Moved Permanently' support, which
httpd does not seem to support at this time. However, httpd does
support FastCGI, so I use a small Perl CGI script called via slowcgi
to set the 301 redirect header.

It is a bit underdocumented that the 'root' httpd option can be
used to tell slowcgi which script to execute.

##httpd.conf##

ext_addr="egress"
server "www.example.com" {
        listen on $ext_addr port 80
}
server "old.example.com" {
        listen on $ext_addr port 80
        fastcgi socket "/run/slowcgi.sock"
        root "/cgi-bin/redir.pl"
}


##redir.pl##

#!/usr/bin/perl -Tw
use CGI;
my $q = CGI->new();
print $q->redirect(
  -location => 'http://www.example.com',
  -status => '301 Moved Permanently',
);

You will also have to setup perl in the chroot and start slowcgi.

Cheers,
Elijah

Reply via email to