3 ms·
> On the other hand, the unreadable weird-ass pseudo-XML configuration files If I have one gripe about NGINX it's that its configuration is a still-half-baked
by nkozyra 5y ago
> On the other hand, the unreadable weird-ass pseudo-XML configuration files
If I have one gripe about NGINX it's that its configuration is a still-half-baked DSL that has quirks you wouldn't expect and when they error you don't get great feedback.
Examples: You can have an if clause, but no else attached. You can't have an if clause with multiple conditions. Finally, "if [might be] evil." 1
You end up writing a bunch of partitioned control flow statements and you're never really sure at what level of config hierarchy they would best be applied.
I love the product but Apache's XML versus NGINX's semi-declarative, hierarchical blocks aren't night and day better.
1 https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/ https://www.nginx.com/resources/wiki/start/topics/depth/ifis...
- taf2 5y agoWith the rewrite and map blocks it is maybe a little easier for you to write fewer if statements…. https://stackoverflow.com/questions/47724946/nginx-rewrite-by-map-with-parameters https://stackoverflow.com/questions/47724946/nginx-rewrite-b...
- nkozyra 5y agoOh I've used these plenty but there are still conditionals which sometimes require or are most clearly defined with if statements, particularly complex redirects that rely on a number of individual conditions to be met. I've seen these manifest in the wild as stuff like: if ($thing ~* (match)) { $setWeirdVar = "Y"; } if ($otherThing = "value") { set $setValue "${setWeirdVar}E"; } if ($thirdCondition ~ (another|match)) { set $setValue "${setWeirdVar}S"; } if ($setValue = YES) { # do a thing here } As clunky as that is, I've found it recommended in SO threads.
- Cyberdog 5y agoI agree with you completely. Nginx's config syntax is better than Apache's but it still feels like mystery meat. Can you use this directive or option within this block? Maybe, maybe not. If not, why? Who knows. It's just not allowed to use map within a location block and that's just how it is, okay? My dream web server has Nginx's capabilities and Lighttpd's Lua configuration files/scripts. Is that what ngx_lua does? I've heard of it before but never really gave it a look.