Hi,
I'm new with nginx, so i just copy paste my nginx.conf from some resources on internet. I just want to know if there's any mistakes or wrong configuration. Here it is
[code]
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------
events {
worker_connections 1024;
}
#----------------------------------------------------------------------
# HTTP Core Module
#
# http://wiki.nginx.org/NginxHttpCoreModule
#
#----------------------------------------------------------------------
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 9;
gzip_proxied any;
gzip_http_version 1.0;
gzip_min_length 1100;
gzip_types text/plain text/css application/x-javascript text/xml application/xml
application/xml+rss text/javascript;
gzip_vary on;
# Load config files from the /etc/nginx/conf.d directory
proxy_cache_path /var/log/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path /var/log/cache/tmp;
include /etc/nginx/conf.d/*.conf;
#
# The default server
#
server {
listen 184.82.20.181:80;
server_name mywebsite.com;
charset utf-8;
access_log /var/log/nginx/mywebsite.access.log main;
#Serve Static Files
location ~ \.(ico|css|js|png|jpg|gif)$ {
root /home/mywebsite/public_html;
expires max;
access_log off;
proxy_cache my-cache;
proxy_cache_valid 200 302 600m;
proxy_cache_valid 404 600m;
}
#Serve XML Files
location ~ \.xml {
root /home/mywebsite/public_html;
proxy_cache my-cache;
proxy_cache_valid 200 302 20m;
proxy_cache_valid 404 600m;
}
location / {
if (-f $request_filename) {
break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
#Block access to contact.php
location ~* (contact|ontact)\.php$ {
return 444;
access_log off;
}
proxy_pass http://127.0.0.1:8008;
expires 15m;
proxy_hide_header Pragma;
proxy_hide_header Cache-Control;
proxy_cache my-cache;
proxy_cache_valid 200 301 302 15m;
proxy_cache_valid 404 600m;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
#Block bad bot
if ($http_user_agent ~* (libwww-perl|libcurl|wget|discobot|Exabot|Casper|kmccrew|plaNETWORK|RPT-HTTPClient)) {
return 444;
access_log off;
}
#Block No user agent
if ($http_user_agent = "") {
return 444;
access_log off;
}
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 300;
proxy_send_timeout 300;
}
#error page
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
[/code]
Thanks in advanced