nginx - configure frontend to ~ username - public_html
Of course, I understand that this may not be necessary for anyone, since I have not found a proper solution on the Internet. However, earlier, when computers were large, and we were small, so-called home pages were popular. A proud Indian even has a module for this business - userdir.
Recently (June, 2009) I decided to drive the Indian into the backend, and configure nginx with the frontend. So I did not find a ready-made solution for organizing the frontend for nginx. Without thinking twice, scratched his chin and rolled the following configuration to nginx. Imagine the happiness I experienced when it worked.
So, the task is to force the frontend to give the contents from the user’s homedir - / home / user / public_html. The request to which in the browser looks like site.name/~user :
Actually that's all :) Extensions for files processed in the frontend
can be invented and added independently to the regular expression.
Naturally, we think up the rest of the configuration ourselves - this is just a template for a note :)
... the journey continues :)
Recently (June, 2009) I decided to drive the Indian into the backend, and configure nginx with the frontend. So I did not find a ready-made solution for organizing the frontend for nginx. Without thinking twice, scratched his chin and rolled the following configuration to nginx. Imagine the happiness I experienced when it worked.
So, the task is to force the frontend to give the contents from the user’s homedir - / home / user / public_html. The request to which in the browser looks like site.name/~user :
location ~ ^ / ~ ([^ /] *) / (. * \. (bmp | jpg | jpeg | gif | ico | png | css | doc | txt | js | zip | iso | tgz | gz | rar | bz2 | 7z | xls | exe | pdf | ppt | tar | wav | avi | rtf | mp3 | mp4 | mov | mpeg | mpg)) {
access_log /var/log/nginx/access-frontend.homedir.site.name.log;
alias / home / $ 1 / public_html / $ 2;
expires 5d;
limit_rate 50k;
}
location ~ ^ / ~ ([^ /] *) / (. *) {
access_log /var/log/nginx/access-backend.homedir.site.name.log;
proxy_set_header Host $ host;
proxy_set_header X-Real-IP $ remote_addr;
proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:60080;
proxy_redirect off;
}
location ~ * ^. + \. (bmp | jpg | jpeg | gif | ico | png | css | doc | txt | js | zip | iso | tgz | gz | rar | bz2 | 7z | xls | exe | pdf | ppt | tar | wav | avi | rtf | mp3 | mp4 | mov | mpeg | mpg) $ {
access_log /var/log/nginx/access-frontend.site.name.log;
expires 5d;
limit_rate 50k;
if ($ http_user_agent ~ FDM | Download) {
limit_rate 50k;
}
}
location = / {rewrite. /index.php last; }
location / {
access_log /var/log/nginx/access-backend.site.name.log;
proxy_set_header Host $ host;
proxy_set_header X-Real-IP $ remote_addr;
proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:60080;
proxy_redirect off;
}Actually that's all :) Extensions for files processed in the frontend
can be invented and added independently to the regular expression.
Naturally, we think up the rest of the configuration ourselves - this is just a template for a note :)
... the journey continues :)