5 ms·
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 40
by marshallford 12y ago
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!
- cheald 12y agoI'm pretty sure the best way to accomplish this is to jump into IRC and declare that it is impossible to be done. You will have 6 answers in 3 minutes.
- marshallford 12y agoI wish, I have tried multiple times and no one wants/can do it.
- gaoshan 12y agoOr say, "Well, this is the only way to do it... nothing else works for nginx." and then present an inefficient solution. You will get ripped but solutions will arrive.
- faster 12y agoCunningham's Law to the rescue! https://meta.wikimedia.org/wiki/Cunningham's_Law https://meta.wikimedia.org/wiki/Cunningham's_Law
- DrJ 12y agothis is literally happening in this thread
- ShaneOG 12y agoHave you checked out https://github.com/h5bp/server-configs-nginx https://github.com/h5bp/server-configs-nginx ?
- marshallford 12y agoYes I have, however I always find it very challenging to modify it to support clean urls and PHP-FPM in an OCD fashion.
- w-ll 12y agoHave you tried handling your urls in php? Most apps/frameworks I've worked on in the past few years all do better url mgmt then you are probably going to get with just nginx configs.
- leeoniya 12y agoalso check out https://gist.github.com/plentz/6737338 https://gist.github.com/plentz/6737338
- deleted 12y ago[deleted]
- michaelbuckbee 12y agoAsk on StackOverflow or ServerFault, offer a bounty if no one answers within a day.
- marshallford 12y agonot a bad idea. Does either have an official way to offer a bounty? If not, any sites that do? Also, what would you say is a fair price range for this kind of request?
- lazyant 12y agoA bounty in those sites is not monetary but you use "karma" points that you win by answering questions etc.
- scragg 12y agoI bet it will get closed for being too localized.
- odonnellryan 12y agoWhat problems exactly with "clean URLs" are you running into?
- marshallford 12y agoIt 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-FPM should be fully supported and not exploitable by the foo.com/random.gif.php bug. 403 and 404 send to /404.html. I am sure I am forgetting something, but that is a start.
- richardjs 12y agoYour 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) rewrite [^^](.*)/$ /$1 permanent; # - Remove .html and .htm extensions # e.g. /foo/bar.htm -> /foo/bar rewrite ^(.*)\.html?$ $1 permanent; # - Remove index file URLs # e.g. /foo/bar/index -> /foo/bar/ # (the trailing slash is then removed by the first rewrite) rewrite ^(.*/)index$ $1 permanent; Edit: There's a couple extra directives that go along with the above to make it work that I neglected to include: # Try the request URI, and a potential index file in the URI (in the case of a directory). # This lets you hit the file WEBROOT/foo/bar/index with the URI /foo/bar, # and hit the file WEBROOT/foo/bar.html with the URI /foo/bar try_files $uri $uri/index $uri.html =404; # You need this (or some other way to provide the type information) # if you don't have extensions on your files. default_type text/html; Also, for error pages, you can probably just use the error_page directive: error_page 404 403 /404; # The .html in your spec will be stripped off by the above rewrite rule
- jafaku 12y agoYou should let your web framework of choice do that. You should be able to find any directives you need to add to your nginx conf in your framework's docs. Typically they will use a Front Controller (eg: app.php or index.php), so you need a directive to map all the dynamic traffic (ie. usually not images or other static files) to that file. Everything else is done by the framework.
- marshallford 12y agoI am designing this Ngnix conf for use on small vanilla sites and static generated sites like Jekyll. (Yes I know Jekyll puts all blog posts in separate folders to solve the URL issue, but I don't want that).
- mrweasel 12y agoYou could pay the Nginx guys to help I suppose.
- eggnet 12y agoYou 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 but not URLs. location / { if ($uri ~ ^/google) { break; } if ($uri ~ ^/y_key_) { break; } if ($uri ~ \.html$) { return 404; } if ($uri = /index) { return 404; } if (!-f $request_filename) { rewrite ^/$ /index.html break; rewrite .* $uri.html break; } }
- Spittie 12y agoBy the way, the nginx wiki says that you should avoid ifs when possible: http://wiki.nginx.org/IfIsEvil 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 .* $uri.html break; }
- marshallford 12y agoThis 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.
- sondr3 12y agoWhat kind of app are you running that requires you to do something like this for clean URLs?
- eggnet 12y agoThanks, I will try this, it looks like it will work.
- nilsbunger 12y agoTry odesk? If you have a clear spec for what you want you can probably get a fixed-price bid.
- marshallford 12y agoEven the word "odesk" leaves a bad taste in my mouth. I have heard a lot of bad things about these kinds of freelance sites.
- nilsbunger 12y agoHave you used them? Like anything, odesk/elance/etc require an investment on your side to make successful. We've found good people through odesk to take on tasks we weren't good at -- front-end javascript, document translation, audio transcription, to name a few.