So I am running a site www.example.com. Initially, I was using apache and any hit to my site would be redirected to www.example.com/path. Now this redirection is defined in my httpd.conf like:

Redirect 301 /index.html http://www.example.com/path

and my VirtualHost setting for this domain looks like this:

    DirectoryIndex  index.php index.html index.htm index.shtml
    ServerAdmin root@www.example.com
    DocumentRoot "/var/www/html"
    ServerName www.example.com

    ScriptAlias /path "/path/to/cgi/script"


So basically when someone visits www.example.com, he is redirected to www.example.com/path which is executes a CGI script as defined by the ScriptAlias directive.

Everything was working fine until I had to do the following:

Install nginx and configured it to act as a reverse proxy for apache.

Now nginx listens to port 80 and apache listens to 8080. I made the changes in httpd.conf file accordingly.

Listen 8080



Now when someone tries to go to www.example.com, he is redirected to www.example.com/path but the script does not seem to execute. I am getting the following error on my web page:

Not Found

The requested URL /path was not found on this server.
Apache/2.4.25 (Unix) PHP/7.0.16 SVN/1.7.14 Server at www.example.com Port 80

The fact that it is redirecting tells me that the request from nginx to apache is working fine. There must be something wrong CGI execution. There is nothing in apache error logs and nginx error logs.

I do not understand this. Everything was working fine with apache but now when the request reaches apache, something breaks.

  • 1
    It is impossible to tell what is wrong with your configuration unless we can see it and the log files. – Tero Kilkanen Mar 11 '17 at 9:50
  • The problem has been fixed. Thanks for the reply. I appreciate it. – Prakarsh Upmanyu Mar 19 '17 at 7:16

I fixed the problem but I don't understand how it got fixed. In my nginx conf, where I forward the request from nginx at port 80 to apache at port 8080, I replaced the line



proxy_pass http://www.example.com:8080;

According to me and www.example.com should be the same as my nginx is installed on www.example.com server.

  • This happens because your application server is bound only to the public interface IP address. It should be only bound to the localhost interface. Check your application server configuration. – Tero Kilkanen Mar 19 '17 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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