Upgrading mysql and configurating my custom 404.html page.

Francis Daly francis at daoine.org
Tue Nov 25 08:20:29 UTC 2014

On Mon, Nov 24, 2014 at 08:38:49PM +0100, Thornx John wrote:

Hi there,

> I have two problems :  Upgrading mysql and configurating my custom
> 404.html page.

The 404 page part may be relevant to this mailing list.

> So I spent days on google without finding solutions, knowing I had
> previously installed csf firewall, Meanwhile I wanted to change the
> default nginx  404 page to my custom 404.html page, my errors html files
> are in the root directory, that I had  configure this default server
> file, but still does not work, and then I can't stop nginx ( "nginx stop
> service."  ) The nginx.pid is missing.

I'm confused as to what exactly you are doing and what exactly you are
seeing and what exactly you are expecting to see.

So take this as "information" rather than "a recipe".

> My website works and mysql too, but I'm stuck here.

Your "netstat" output suggests that nginx is running as pid 4647 and
listening on port 81.

If you manually "kill" that pid, then that will probably cause your
current nginx to exit.

(Don't do that until you want to, of course.)

Then the "normal" nginx commands can be used to confirm that your config
file is syntactically correct, and can be started and stopped. If you
use any "wrapper" commands to do that, make sure that they refer to the
binaries and config files that you want them to.

>         ##
>         # Uncomment it if you installed nginx-naxsi
>         ##
>         include /etc/nginx/naxsi_core.rules;

I do not know what naxsi is, so I do not know what is involved in
that "include" file. If it breaks normal nginx semantics, then you'll
probably want to ask naxsi people for help. If it doesn't, then this
should work as-is.

>         ##
>         # Virtual Host Configs
>         ##
>         include /etc/nginx/conf.d/*.conf;
>         include /etc/nginx/sites-enabled/*;

Potentially, every one of those files matter.

I am only working off the partial config you have shown here.

If you need to understand the whole thing, you may prefer to remove most
of those files so that you have a small and understandable config file,
and then add in other pieces one at a time.

>         root /var/www/;
>         index index.html index.htm index.php
>          error_page 404 /404.html;

So, any 404 error is handled by the url /404.html, which (unless other
configuration overrides it) corresponds to the file /var/www/404.html.

>          location = /40x.html {

This configuration does not apply to the url /404.html

>         location / {

This configuration can apply to the url /404.html; and is the one that
will apply (based on the other location{} blocks in this server{}.

>                 # First attempt to serve request as file, then
>                 # as directory, then fall back to displaying a 404.
>                 try_files $uri $uri/ /index.html;

The comment says one thing; the config directive says another. This line
will never cause a 404 to be raised. Anything that might have caused a
404 will instead return the content of /var/www/index.html...

>                 # Uncomment to enable naxsi on this location
>                  include /etc/nginx/naxsi.rules;

...unless that causes something else to happen.

(And if /var/www/index.html does not exist, you'll probably get a
500-series error.)


what request do you make where you expect a 404?

What response do you actually get instead?

("curl -i" is usually good for showing this.)

As to the solution -- it depends on what you want to have happen; and
it is not clear to me from this mail what that is.

Perhaps remove every configuration directive that you do not understand,
and see what happens on your test system? Add things back one at a
time? Then when things work there as you expect, transfer the config to
your live system?

Good luck with it,

Francis Daly        francis at daoine.org

More information about the nginx mailing list