Skip to content

Instantly share code, notes, and snippets.

@mightydes
Last active August 29, 2015 13:56
Show Gist options
  • Save mightydes/9271889 to your computer and use it in GitHub Desktop.
Save mightydes/9271889 to your computer and use it in GitHub Desktop.
Nginx
# any php file
location ~ \.php$ {
# drop 404 on file not found
try_files $fastcgi_script_name =404;
# or route to index.php on file not found
#try_files $fastcgi_script_name /index.php?$args;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ ^/(index|app|config|some/api)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location / {
access_log off;
proxy_pass http://{ip};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
server {
listen 80;
server_name uploads.example.com;
location ~ ^.+\.(jpeg|gif|png|jpg) {
access_log off;
add_header Cache-control "public";
expires 90d;
proxy_pass http://127.0.0.1:8890;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment