I'm having a problem with nginx where my ip address points to my website but when i point my domain to that ip address, and try to access my webstie with my domain name (www.example.com) nginx returns a 404 error. Here is my code.
user www-data;
worker_processes 4;
worker_rlimit_nofile 100000;
pid /run/nginx.pid;
events {
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 200;
reset_timedout_connection on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
#gzip on;
gzip_disable "msie6";
gzip_min_length 256;
# gzip_vary on;
# gzip_proxied any;
gzip_comp_level 3;
gzip_buffers 16 32k;
# gzip_http_version 1.1;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
server{
listen 80;
server_name vidzapp.com www.vidzapp.com;
client_max_body_size 500m;
location /{
add_header 'Access-Control-Allow-Origin' "*";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Content-Type,accept,x-wsse,origin';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
root /var/www;
index index.php;
}
location ~ \.php$ {
root /var/www/;
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;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
}
In your virtual Host file located @ /etc/nginx/sites-available/yourdomain.com
FIND AND ADD : DOMAIN.com www.DOMAIN.com *.DOMAIN.com; to server name
root /var/www/egaffar.com/datazone;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name DOMAIN.com www.DOMAIN.com *.DOMAIN.com;
location / {
# First attempt to serve request as file, then
Then type the below command
nginx -t && service nginx restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With