Live data from Hacker News

Nginx 1.6.0 stable released

nginx.org

61–70 of 114 posts

Re: Nginx 1.6.0 stable released

#61
post #59
post #38

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…

This is yet another concern of mine. Most of my solutions involve at least 3 if statements. But I need them in order to check if a requested url is a directory or a file and such.

Re: Nginx 1.6.0 stable released

#62
post #38

I 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…

I don't mean to be blunt, but using if is not the way: http://wiki.nginx.org/IfIsEvil

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

#64
post #13

Slightly 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…

https://niklaslindblad.se/2014/03/build-statically-compiled-...

Re: Nginx 1.6.0 stable released

#65

Earlier 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…

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

#66
post #65

Earlier 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

I am designing this Ngnix conf for use on small vanilla sites and static generated sites like Jekyll. Otherwise, yes I would rely on my CMS's index file.

Re: Nginx 1.6.0 stable released

#67
post #49

Earlier 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…

No, it doesn't redirect.

    $ curl -I https://www.google.com/
    HTTP/1.1 200 OK

Re: Nginx 1.6.0 stable released

#68
post #56
post #50

Earlier 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.

this reminds me of a government agency that permits access by IP addresses whitelisted in IIS. Can't put fancy caching or load balancing in front because it can't understand X-Forwarded-For, etc.

tl;dr build your authentication into your app, not the web server layer.

Re: Nginx 1.6.0 stable released

#69
post #59
post #38

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…

Thanks, I will try this, it looks like it will work.

Re: Nginx 1.6.0 stable released

#70

Earlier 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…

I have had problems using rewrite in this way. The URL that rewrite analyses may have already been changed by `index` or some other command, and this will lead to redirect loops. To avoid that problem, I have used:

    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.
Post reply on HN