Earlier quoted context omitted.
You didn't really specify what you meant by clean URLs but, maybe this will be helpful to you or someone else. I have a static site served via nginx, but I don't like seeing .html in the URLs. It's a little tricky serving a static site without the .html extension because you may have a directory and an html page with the same name. The way to deal with that is to actually use the .html extension in the file system bu…
By the way, the nginx wiki says that you should avoid ifs when possible: http://wiki.nginx.org/IfIsEvil Wouldn't something like this accomplish the same thing? (Sorry if I'm totally wrong, I'm not really good) location /google/ { } location /y_key_/ { } location ~ \.html$ { return 404; } location = /index { return 404; } location / { try_files $uri @rewrite } location @rewrite { rewrite ^/$ /index.html break; rewrite…
Nginx 1.6.0 stable released
61–70 of 114 posts
Re: Nginx 1.6.0 stable released
#62I figure this is as good of place as any to ask my question: Where can I find someone to hire that is able to write Nginx cofigs well. I have spent literally 40ish hours trying to create a Nginx conf that holds up to my OCD. I have been told numerous times on IRC that I am too picky and clean urls are a challenge to write. I am college student and System Administration isn't even my job! Help!
You didn't really specify what you meant by clean URLs but, maybe this will be helpful to you or someone else. I have a static site served via nginx, but I don't like seeing .html in the URLs. It's a little tricky serving a static site without the .html extension because you may have a directory and an html page with the same name. The way to deal with that is to actually use the .html extension in the file system bu…
Writing clean URLs is much easier with try_files, which allows you to do something like
try_files $uri.html
If you don't want to see file extensions.Re: Nginx 1.6.0 stable released
#63Waiting for package for Ubuntu 12.04 and crossing my fingers that it comes with SPDY enabled so I don't have to compile it. I know, I am lazy :P.
Re: Nginx 1.6.0 stable released
#64Slightly OT: Does anyone know if packages for Ubuntu 14.04 are coming soon? We're using the official (mainline) repository[1] on Ubuntu 12.04, but Trusty doesn't seem to be supported yet. I've always preferred the official repository because I didn't want to start compiling nginx just for stuff like SPDY support. [1]: http://nginx.org/en/linux_packages.html
It's a good idea to be comfortable compiling/packaging your infra from source (including interpreters, libraries, etc), if only for the ability to quickly apply and deploy emergency patches. To demonstrate the importance of that capability, look no farther than Heartbleed. While distros are usually pretty good about updating critical software, they shouldn't be your only line of defense, except perhaps if you have a…
Re: Nginx 1.6.0 stable released
#65Earlier quoted context omitted.
What problems exactly with "clean URLs" are you running into?
It is a lot to get into now, but here is a taste. foo.com/index > foo.com foo.com/ > foo.com foo.com/folder/index > foo.com/folder/ foo.com/bar.html > foo.com/bar foo.com/bar.htm > foo.com/bar foo.com/bar.php > foo.com/bar www.foo.com/ ANY OF THE ABOVE TESTS > foo.com/* other rules: Never add trailing slash unless it is an index file of a directory. Order: .PHP,.HTML,.HTM. Use h5bp/server-configs-nginx as a base. PHP…
Re: Nginx 1.6.0 stable released
#66Earlier quoted context omitted.
It is a lot to get into now, but here is a taste. foo.com/index > foo.com foo.com/ > foo.com foo.com/folder/index > foo.com/folder/ foo.com/bar.html > foo.com/bar foo.com/bar.htm > foo.com/bar foo.com/bar.php > foo.com/bar www.foo.com/ ANY OF THE ABOVE TESTS > foo.com/* other rules: Never add trailing slash unless it is an index file of a directory. Order: .PHP,.HTML,.HTM. Use h5bp/server-configs-nginx as a base. PHP…
What you need to do is route EVERY request to your 'index.php` or equivalent, show errors from there. It would look like this: ^ index.php
Re: Nginx 1.6.0 stable released
#67Earlier quoted context omitted.
foo.com/* -> www.foo.com/* seems "cleaner" to me than your opposite, due to the issues with cookie leaking, CDN hosting, "normal user" expectations, etc. Like, please appreciate that your usage of "cleaner" is at best subjective ;P. (And I don't quite understand how you are intending to do "foo.com/ -> foo.com"... all URLs must have a path: you can't just GET, you have to GET /.)
I understand the redirecting to non-www is subjective, however I find less characters in the URL is cleaner. Also for a majority of my projects cookies are not used, so it is not a big deal to use a non-www base url.(Static blogs and simple vanilla sites for various school projects, etc). Also as far as foo.com/ -> foo.com, I was referring to the URL, not the acutal path. example: https://www.google.com/ redirects to…
$ curl -I https://www.google.com/
HTTP/1.1 200 OKRe: Nginx 1.6.0 stable released
#68Earlier quoted context omitted.
>Perhaps nginx might instead check all requests for a particular signed cookie... That's called session handling, which is something you want to implement in your web application, not your web server. http://en.wikipedia.org/wiki/HTTP#HTTP_session_state http://en.wikipedia.org/wiki/Stateless_protocol
In some cases it would be useful to perform session handling like this in nginx. I like the idea of building a reverse proxy which handles authentication and sessions, in front of a backend web page which wasn't designed to handle it. Something like giving access to an old internal intranet without having to change the app.
tl;dr build your authentication into your app, not the web server layer.
Re: Nginx 1.6.0 stable released
#69Earlier quoted context omitted.
You didn't really specify what you meant by clean URLs but, maybe this will be helpful to you or someone else. I have a static site served via nginx, but I don't like seeing .html in the URLs. It's a little tricky serving a static site without the .html extension because you may have a directory and an html page with the same name. The way to deal with that is to actually use the .html extension in the file system bu…
By the way, the nginx wiki says that you should avoid ifs when possible: http://wiki.nginx.org/IfIsEvil Wouldn't something like this accomplish the same thing? (Sorry if I'm totally wrong, I'm not really good) location /google/ { } location /y_key_/ { } location ~ \.html$ { return 404; } location = /index { return 404; } location / { try_files $uri @rewrite } location @rewrite { rewrite ^/$ /index.html break; rewrite…
Re: Nginx 1.6.0 stable released
#70Earlier quoted context omitted.
It is a lot to get into now, but here is a taste. foo.com/index > foo.com foo.com/ > foo.com foo.com/folder/index > foo.com/folder/ foo.com/bar.html > foo.com/bar foo.com/bar.htm > foo.com/bar foo.com/bar.php > foo.com/bar www.foo.com/ ANY OF THE ABOVE TESTS > foo.com/* other rules: Never add trailing slash unless it is an index file of a directory. Order: .PHP,.HTML,.HTM. Use h5bp/server-configs-nginx as a base. PHP…
Your specs look a lot like ours (we have a CMS that adds a trailing /index to every page that is part of the core navigation, and we don't want that). Here's the three primary rewrite rules we use for the issue; they don't match your spec exactly, but they might help you get started: # - Remove trailing slashes (except root /) # e.g. /foo/bar/ -> /foo/bar # ([^^] matches every character but the start of the string) r…
if ($request_uri ~* "^(.*)\.html?$") {
return 301 $1;
}
The above is a safe use of "if", and can be helpful since it operates on the actual uri, not the internal uri.