• 맑음동두천 -8.9℃
  • 맑음강릉 -2.4℃
  • 맑음서울 -5.1℃
  • 흐림대전 -3.2℃
  • 구름조금대구 -3.6℃
  • 맑음울산 -2.7℃
  • 광주 -1.3℃
  • 맑음부산 -1.5℃
  • 흐림고창 -3.3℃
  • 흐림제주 6.2℃
  • 맑음강화 -8.4℃
  • 흐림보은 -5.2℃
  • 맑음금산 -5.1℃
  • 구름많음강진군 -4.0℃
  • 흐림경주시 -5.5℃
  • 맑음거제 -0.5℃
기상청 제공

nginx 404 error_page

  • 등록 -0001.11.30 00:00:00
server {
    listen       80;
    server_name  server;
    access_log  /var/log/httpd/nginx-access.log;
    root /home/$host/www;
 
    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid    30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors   on;
 
    location / {
      root /home/$host/www;
      index index.html index.php index.cgi index.htm;
    }

    error_page  404         = @notfound;
    location @notfound {
      try_files /404.html /home/$host/www/404.html =404;
    }
 
    location ~* ^.+.(jpg|gif|png|css|js|jpeg|swf)$ {
      root /home/$host/www;
    }

    location ~ .(php|html|htm)$ {
      proxy_pass  http://lighty;
      proxy_redirect off;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_read_timeout 20;
      proxy_connect_timeout 20;
      client_body_temp_path      /opt/webapps/nginx/client_body_temp;
    }

    location = /404.html {
      internal;
    }
  }