• nginx: turn a 404 into a 302 found?

    From Eli the Bearded@21:1/5 to All on Tue Aug 14 18:45:23 2018
    I've done most of work with websevers using Apache. I'm trying to learn
    the ways of Nginx for comparison. The pieces certainly fit together
    differently with Nginx.

    Here's a rough overview of what I have:

    * main page of the site is a CGI using fastcgi
    * this page mostly just issues redirects (302)
    for the purposes of discussion, the redirect issued can be
    considered random and constantly different (hence need for CGI)
    (in actuality, it's deterministic)
    * when someone requests a file besides the main page, if it
    exists, I want people to reach it
    * when someone requests a file that is a 404, I want the main
    page CGI to run, so I added to the conf:
    error_page 404 /index.cgi;

    That all works. But the main page issues a "Status: 302" and a
    "Location:" header, yet clients requesting a bad URL never see
    a "HTTP/1.1 302 Found" response, instead they get a "HTTP/1.1 404
    Not Found" which includes a "Location" header.

    So is this something I fix in Nginx? Fastcgi? My CGI script? What's the
    trick for converting the 404 to a new status?

    Elijah
    ------
    not sure where to begin searching for that

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to *@eli.users.panix.com on Wed Aug 15 19:11:34 2018
    In comp.infosystems.www.servers.unix,
    Eli the Bearded <*@eli.users.panix.com> wrote:
    Here's a rough overview of what I have:

    * main page of the site is a CGI using fastcgi
    * this page mostly just issues redirects (302)
    for the purposes of discussion, the redirect issued can be
    considered random and constantly different (hence need for CGI)
    (in actuality, it's deterministic)
    * when someone requests a file besides the main page, if it
    exists, I want people to reach it
    * when someone requests a file that is a 404, I want the main
    page CGI to run, so I added to the conf:
    error_page 404 /index.cgi;

    That all works. But the main page issues a "Status: 302" and a
    "Location:" header, yet clients requesting a bad URL never see
    a "HTTP/1.1 302 Found" response, instead they get a "HTTP/1.1 404
    Not Found" which includes a "Location" header.

    So is this something I fix in Nginx? Fastcgi? My CGI script? What's the
    trick for converting the 404 to a new status?

    I've been able to get it working a little better by using a double
    redirect. All 404s get a fixed redirect to the mainpage and then the CGI
    runs and gives the second redirect. Still not ideal, but better.

    Elijah
    ------
    expects most 404s to come from people nosing about

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)