るいすのブログ

オタクエンジニアの雑記

nginxの設定がよく分からず...。


prineville-servers-1000

ウッ

現在の自鯖のWebサーバーソフトウェアがnginxなのですが やはり扱いきれず意味不な状態

Ubuntuなnginxなphp-fpmなサーバーが不安定です。

Ubuntu+nginxの力はどれほどのものなのか。

何かがおかしい。nginxにしたら閲覧数・訪問者が激減した話。

アクセス解析ソフトである”Webalizer"を導入したのですが http://localhost/webalizer と開くと403 , 404 のどちらかが返されます。

nginx側のlogフォーマット Webalizerの出力先も/var/www とサーバードキュメントにしているんですけどねぇ(`;ω;´)

どなたか分かる方いますかね。

nginx.conf

[source]

user www-data; worker_processes 2; pid /var/run/nginx.pid;

events { worker_connections 4096; # multi_accept on; }

http { client_max_body_size 128M; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'; ## # Basic Settings ##

sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; 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_vary on; gzip_proxied any; gzip_comp_level 9; gzip_buffers 16 8k; gzip_http_version 1.0; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

#

# 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 ##

proxy_cache_path /var/cache/nginx/cache levels=1 keys_zone=luis:4m inactive=7d max_size=50m;

proxy_temp_path /var/cache/nginx/temp;

proxy_cache_key "$scheme://$host$request_uri"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

upstream backend { ip_hash; server 127.0.0.1:8080; }

include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/luispc.com; proxy_connect_timeout 3000; proxy_send_timeout 3000; proxy_read_timeout 3000; fastcgi_connect_timeout 3000s; fastcgi_send_timeout 3000s; fastcgi_read_timeout 3000s; send_timeout 1800s; } [/source]

luispc.com

[source]

server { listen 8080; server_name luispc.com; access_log /var/log/nginx/luis/access.log; error_log /var/log/nginx/luis/error.log; client_max_body_size 128M;

location / { root /var/www; index index.php; client_max_body_size 128M; try_files $uri $uri/ /index.php; }

location /luis/ { auth_basic "admin only"; auth_basic_user_file /var/www/luis/.htpasswd; }

location /webalizer/ { root /var/www/webalizer; index index.html index.htm; access_log off; }

location ~ .php$ { root /var/www; include /etc/nginx/fastcgi_params; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name; fastcgi_pass_header "X-Accel-Redirect"; fastcgi_pass_header "X-Accel-Expires"; client_max_body_size 128M; }

location ~ /.ht { deny all; client_max_body_size 128M; } }

server { listen 80; server_name luispc.com; location /wp-admin { proxy_pass http://backend; } location /wp-content/plugins { proxy_pass http://backend; } location ~ ..php { proxy_pass http://backend; } location / { set $mobile ""; if ($http_user_agent ~ '(DoCoMo|J-PHONE|Vodafone|MOT-|UP.Browser|DDIPOCKET|ASTEL|PDXGW|Palmscape|Xiino|sharp pda browser|Windows CE|L-mode|WILLCOM|SoftBank|Semulator|Vemulator|J-EMULATOR|emobile|mixi-mobile-converter)') { set $mobile "@ktai"; } if ($http_user_agent ~ '(iPhone|iPod|Opera Mini|Android.Mobile|NetFront|PSP|BlackBerry)') { set $mobile "@mobile"; } if ($http_cookie ~* "comment_author|wordpress(?!test_cookie)|wp-postpass_" ) { set $do_not_cache 1; }

location /nginx_status { stub_status on; access_log off; }

location /munin { stub_status on; access_log off; }

proxy_no_cache $do_not_cache; proxy_cache_bypass $do_not_cache; proxy_cache luis; proxy_cache_key "$scheme://$host$request_uri$is_args$args$mobile"; proxy_cache_valid 200 301 302 100m; proxy_cache_valid 404 50m; proxy_pass http://backend; client_max_body_size 128M; } } [/source]