Skip to content

Instantly share code, notes, and snippets.

@alsyundawy
Forked from 0xAsuka/cdn-nginx.conf
Created March 1, 2018 11:30
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save alsyundawy/5b54f8c6023ffbdc5af272d09c51e9c2 to your computer and use it in GitHub Desktop.
Save alsyundawy/5b54f8c6023ffbdc5af272d09c51e9c2 to your computer and use it in GitHub Desktop.
Nginx CDN Server Configuration
server {
listen 80;
server_name cdn.domain.org;
root /usr/share/nginx/cdn
location / {
proxy_pass http://domain.org;
proxy_set_header Host $host;
proxy_set_header True-Client-IP $remote_addr;
}
location ~* .(jpg|png|gif|jpeg|webp|css|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
expires max;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://domain.org;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
proxy_store /usr/share/nginx/cdn$uri;
proxy_store_access user:rw group:rw all:r;
}
#blokir htaccess
location ~ /\. { deny all; }
#blokir temp file dengan awalan $
location ~ ~$ { deny all; }
#blokir akses php file
location ~ \.php$ { deny all; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment