I have a server with Nginx 1.4 in Ubuntu 14.04 and it’s running with PHP5-fpm. The server has multiple domains and sub-domains in a Private cloud server. The server is getting consistent hits from traffic and it’s lot. Everything is fine, but Nginx frequently returns 404, while the case is not in actual and after couple of try it returns the actual output instead of 404. Below is one example of my one of the server block from nginx config.
server {
listen 80;
#listen [::]:80;
root /var/www/appfolder;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name domain-name;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/appfolder;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Please help me on this, I have searched a lot, but never got a proper solution. Thanks in advance.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
@Mohsen47 @hansen Below are some latest http requests:
47.62.115.161 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=addAction HTTP/1.1" 200 55 "-" "okhttp/3.6.0"
112.215.65.176 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=addAction HTTP/1.1" 200 56 "-" "okhttp/3.6.0"
120.188.93.200 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=addAction HTTP/1.1" 200 55 "-" "okhttp/3.6.0"
112.215.240.62 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=addAction HTTP/1.1" 404 151 "-" "okhttp/3.6.0"
31.39.201.71 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=addAction HTTP/1.1" 404 151 "-" "okhttp/3.6.0"
212.96.90.104 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=addAction HTTP/1.1" 200 54 "-" "okhttp/3.6.0"
217.73.129.122 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=showCoins HTTP/1.1" 404 151 "-" "okhttp/3.2.0"
77.4.213.189 - - [24/Jul/2017:12:41:18 +0000] "POST /index.php?mode=addAction HTTP/1.1" 404 151 "-" "okhttp/3.6.0"
You can see for the same action it’s getting 404 and 200 both but 404 maximum time.
If the problem is with the database connection, then it’s very strange, that the script returns 404-errors. You need to verify that.
To scale MySQL for a 1000 connections doesn’t require more than changing the max_connections = 1001, but there a lot of other parameters to look at and it depends on read-write levels:
https://tools.percona.com/ - The wizard is a good, easy tool
https://github.com/major/MySQLTuner-perl - The tuner gives you some good hints
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.