안녕하세요.


웹서버를 apache에서 nginx로 변경했습니다.


변경하면서.. 404 not found, 502 bad gateway, many too redirect등등.. 이겨내고 얻어낸 설정값입니다.


코드이그나이터 프레임워크를 쓰기 위한 설정 알려드립니다.


server{

listen 8500 ssl; //listen port 입니다.

server_name localhost;

ssl on;

access_log /var/log/nginx/ssl_access.log main;

error_log /var/log/nginx/ssl_error.log warn;


#ssl 설정

ssl_certificate      /etc/pki/tls/certs/localhost.crt;

ssl_certificate_key  /etc/pki/tls/private/localhost.key;

ssl_session_cache shared:SSL:1m;

      ssl_session_timeout  5m;

ssl_ciphers  HIGH:!aNULL:!MD5;

      ssl_prefer_server_ciphers   on;


#웹서버 경로입니다

      root /var/www/html;

#웹서버로 처음 진입하면 이 세가지 확장자를 확인합니다. 우선순위는 처음부터 1,2,3

index index.html index.htm index.php;


location ~* \.(ico|css|js|gif|jpe?g|png)$ {

expires max;

add_header Pragma public;

try_files $uri /index.php;

}


#root location 설정

location / {

try_files $uri $uri/ @rewrites;

}    


#rewrites 설정 rewrite란 해당 규칙에 맞게 url 재작성을 해줍니다. 

location @rewrites {

          if (!-e $request_filename)

          {

              rewrite ^/(.*)$ /index.php/$1 last;

               break;

           }

      }


      #favicon.ico request off

      location = /favicon.ico {

          access_log off;

          log_not_found off;

      }

      location ~ /\. {

          access_log off;

     log_not_found off;

          deny all;

      }


#PHP Configs

fastcgi_intercept_errors on; 

location ~ \.php {

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;


fastcgi_param QUERY_STRING $query_string;

fastcgi_param REQUEST_METHOD $request_method;

fastcgi_param CONTENT_TYPE $content_type;

fastcgi_param CONTENT_LENGTH $content_length;


fastcgi_param SCRIPT_NAME $fastcgi_script_name;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param REQUEST_URI $request_uri;

fastcgi_param DOCUMENT_URI $document_uri;

fastcgi_param DOCUMENT_ROOT $document_root;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param SERVER_SOFTWARE nginx;


fastcgi_param REMOTE_ADDR $remote_addr;

fastcgi_param REMOTE_PORT $remote_port;

fastcgi_param SERVER_ADDR $server_addr;

fastcgi_param SERVER_PORT $server_port;

fastcgi_param SERVER_NAME $server_name;


fastcgi_index index.php;

fastcgi_pass 127.0.0.1:9000;

}

}

+ Recent posts