Skip to content

Instantly share code, notes, and snippets.

@ibin79
Last active December 11, 2015 09:21
Show Gist options
  • Save ibin79/c027285c8058e707fa95 to your computer and use it in GitHub Desktop.
Save ibin79/c027285c8058e707fa95 to your computer and use it in GitHub Desktop.
xe3-dev Nginx 설정 예제
server {
listen 80;
server_name xe3.php79.net;
root /home/xe3/public;
client_max_body_size 50m;
access_log /var/log/nginx/xe3.access.log main;
#charset utf-8;
location / {
index index.php;
# Laravel Pretty URLs - http://laravel.com/docs/5.1/installation#basic-configuration
try_files $uri $uri/ /index.php?$query_string;
}
# Add expire header for browser caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico|wav|swf|eot|woff|woff2)$ {
expires 14d;
#expires 1h;
#log_not_found off;
}
# 주의) 접근 제한 설정은 PHP FastCGI 설정보다 먼저 선언되어야 합니다.
# 시스템 디렉토리 제한
location ~ ^/(app|bootstrap|config|core|database|migrations|resource|tests|vendor)/ {
deny all;
}
# 스토리지 디렉토리 제한
location ~ ^/storage/(interception|logs|framework)/ {
deny all;
}
# 주요 숨김 파일 제한. ex) .env & .git/
location ~ /(\.) {
deny all;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
@ibin79
Copy link
Author

ibin79 commented Nov 27, 2015

fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/; 설정은 2개 이상 사이트가 같은 php fpm pool 을 사용할 경우, 서로 다른 사이트의 open_basedir 값으로 인식되는 문제가 발견되어 생략함.

php 5.6 + opcache 기준

@ibin79
Copy link
Author

ibin79 commented Dec 11, 2015

XE3 프로젝트에 Nginx 예제 추가 예정중... - xpressengine/xpressengine#34

@ibin79
Copy link
Author

ibin79 commented Dec 11, 2015

스토리지 디렉토리를 전체 차단하는 것은 xpressengine/xpressengine#44 에서 논의중...

따라서 우선 현재 설정에 맞도록, storage/app 등은 접근 가능하고 나머지만 제한하도록 변경.

^/storage/(interception|logs|framework)/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment