ci4.x 기준
1. CLI 전용으로 변경
// CLI(터미널)에서만 실행 가능
if (!is_cli()) {
throw new \CodeIgniter\Exceptions\PageNotFoundException();
}
2. 서버 IP만 허용 (htaccess or 컨트롤러)
$allowedIPs = ['127.0.0.1', '서버IP'];
if (!in_array($this->request->getIPAddress(), $allowedIPs)) {
throw new \CodeIgniter\Exceptions\PageNotFoundException();
}
3. .htaccess로 차단 (apache)
<FilesMatch "exchange">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</FilesMatch>
4. Nginx 설정
/etc/nginx/sites-available/your-site.conf 추가
location /exchange {
allow 127.0.0.1;
# allow 서버IP; # 필요시 추가
deny all;
}
sudo nginx -t # 문법 검사
sudo systemctl reload nginx
| 다음글 | FCPATH 상수 |
|---|