Hacker News new | ask | show | jobs
by throooooo 17 days ago
I have a lot of Linux sysadmin experience but haven't touched Apache in more than a decade. I thought it's mostly nginx or other solutions at this point.
12 comments

Apache has a feature that no other http server has replicated: .htaccess files.

They provide limited configurability of server functionality within a webroot. That's extremely convenient for PHP webapps. For many PHP apps, deploying them on anything that is not apache means touching the server config itself.

I would say that's actually a misfeature as it requires too many additional filesystem lookups to fulfil requests.

Modifying the web server config is a nonissue outside of shared hosting, which should have died out with the advent of VMs/containers.

> I would say that's actually a misfeature as it requires too many additional filesystem lookups to fulfil requests.

Its use is optional: set "AllowOverride None" (the default) and it's disabled.

* https://httpd.apache.org/docs/2.4/mod/core.html#allowoverrid...

But then that removes the "feature Apache has that no other webserver does" and brings back GGP's point about "what does Apache offer over other webservers like nginx"
> But then that removes the "feature Apache has that no other webserver does" […]

Disabling the feature does not remove it.

If I do not turn on my car's windshield wipers, do they get "removed"?

But, if we concede that it's a misfeature (and that it's not valid to criticize the project for having it, as it can be disabled), then what advantage is there in having it?

You can't have it both ways. Either it's a misfeature but it 'doesn't matter' because it can be disabled, or its a legitimate feature in which case you must therefore defend the existence and purpose of the feature.

But you can selectively use the option: allowing the feature where it is useful (user web dirs perhaps, or individual dirs even more selectively) and disabling it elsewhere.
> … too many additional filesystem lookups …

Caching is a thing. Only dump the cache when a changed is noticed.

And now you have 2 problems..
I believe the OS actually caches it, and since you only modify it by interacting with the OS, the cache gets invalidated when needed.
Network filesystems, consequences of mount shadowing, crazy access control extensions, etc.. Trying to recursively monitor directories with a htaccess file in them to know if a URL requested will reach one.. It is a typical layered system problem.
Webserver/filesystem management, cache invalidation, and off-by-one errors.
Your forgot naming things :)
what about ~/public_html dirs on shared servers? Having the ability to have .htaccess there means users can impose access control without being able to modify the server config (which they shouldn't be able to do!).
Why shared hosting should die? It's still the cheapest way to publish a dynamic website.
Shared hosting was and still is a great idea, IMHO it just should be limited to static files, not running server-side webapps.
Does not Microsoft's IIS also have that with web.config files?
Does IIS run on Linux?
Yes, but then you're dealing with IIS and why would you want that?
When your Wordpress site gets hacked the hackers are going to assume that you are running apache or nginx and put a .htaccess in the site root that messes the site up. When you are running on IIS the hackers can put in as many .htaccess files they feel like, it will not make any difference.

Perfect security.

> Perfect security.

sigh

Indeed, but it's interesting how web serving in general has shifted away from files. In the original era of web servers, the path component of the URL was the filesystem path on the web server; these days, we expect to match it against a table of routes. Even most PHP apps use routing takes. If you want to bring things back to the filesystem you don't just need to bring back .htaccess - you need a whole new framework.
> Apache has a feature that no other http server has replicated: .htaccess files.

That can expose your files for such a trivial reason as different end of line sequence than what it expects. Instead of shutting down the access, it just happily ignores .htaccess and enables DirectoryIndex.

This is the software that's responsible for majority of data leaks in the world.

Stop using it.

Ah yes, htaccess. Another lovely source of security bugs for the past 30 years and may it continue to bear skiddie fruit for another 300.

Its model is fundamentally flawed precisely because it was based on the fundamentally flawed PHP model (website assets and code are stored and hosted from the same webroot). This allowed for shared hosting to exist but containers and reverse proxies are a far better way of organising such sites today.

The fact that in other webservers the server's configuration is configured through its configuration file and not the content of its webroot is a feature.

Yes apache has a config file too amazingly enough, .htaccess is optional
The point I was making is that having alternative sources of configuration (coming from the contents being served no less) is a misfeature.

Really not sure how one could possibly read my comment as me saying htaccess is the only way of configuring Apache?

PHP can go to hell. My hair is gray because of it. Nginx is superior, and I can get anything imaginable done with config files. And not to mention, it's much faster.
The http servers drag race finished 15 years ago on a tie, it's really much a matter of taste and familiarity more than performance at this point.
The lazy bastard in me prefers Caddy.
I don't understand this. NGINX can run PHP. PHP is not exclusive to Apache.
In general, the Apache php mod has had less drama than php-fpm over the years. Also, casting each domain under specific isolated itk server user(s) account(s) adds a layer of containment, where Nginx processes must run under a single user context.

Nginx uses way less memory in most use-cases (1/4 to 1/10), but with dynamic content like php it is only slightly better (maybe 15% if lucky). Also, setting up websocket proxy in Nginx is still a bit of a bodge.

Each server type has its own trade offs, and a list of known mitigations the uninitiated must learn. If you have a single domain high-traffic site with static media files, than Nginx is probably going to matter more. =3

There is a way nginx/fpm to host multiple domain where each domain has its own user and group and they maintain 0750 permissions so they can't see eachother but nginx and php can both access them:

- php-fpm is easy, you can make the pool run as the domain's user/group directly

- nginx: you must add nginx's user (www-data) to the domain personal's group

The downside to this approach is that it's harder to reason about for someone unfamiliar with it and it's easy to misconfigure file permissions. There is also a limited number of extra groups a user can be part of before it becomes an issue (plus one fpm pool per user takes memory).

That being said the best massively-shared hosting system I've ever used was apache mpm_prefork with mod_php and mod_ruid2. It used as much(little) memory as a single user setup, it scaled to 10k users if you wanted, and file permissions were all naturally handled.

The way mod_ruid2 worked was to use linux capabilities to change the effective user/group of the apache process before serving the request, so it would run as the tenant's group and user, then switch back to nobody/nobody. It had very little overhead compared to things like mod_suphp and, more importantly, it also worked on static files and .htaccess!

The module has been abandoned and was never that popular so I always wondered if it was found to be exploitable or something... Thanks to Linux Capabilities an exploiter couldn't gain root, but as seen from the recent exploit apache's mod_php doesn't do a full cleanup so maybe there was leakage when the process was reused (but then that is solvable by limiting the requested to 1)

Eh. You can use .htaccess in nginx too. I use that everyday.
At least 21% of web sites use Apache httpd, and of course many sites don’t report the software used at all. Nginx is also frequently used as a reverse proxy, with Apache used behind it.
Apache has plenty of life left, it just works™, supports almost everything, and currently is about as efficient as nginx WRT connection handling. Sometimes you want what .htacces gives you. (No built-in Lua though.)
It's in the "module for almost everything" department.
i mostly use nginx lua to patch on some feature i had even on bare Apache, let alone all the core modules.
> (No built-in Lua though.)

I thought mod_lua was an official module. I've just checked with Debian stable, and their "apache2-bin" package depends on liblua5.

> Apache has plenty of life left

I would expect a project with "plenty of life left" to support HTTP3. And to use Git (or some modern DVCS) instead of Subversion.

BTW, a co-worker has to maintain an Apache server because its shibboleth mod is mandatory for that project, and he often complains about it, and so do I when they ask for help. Performance is worse than nginx, configuration is awful, documentation is uneven, some features (like .htaccess) are dangerous, etc.

Apache http is the only project that I know that still uses Subversion. They have published a Git clone on Github, but their main source is still svn. It's a bit worrying, because they won't attract new developers with that technical stack. Last I checked, the 2.5 branch looked dead, and the dev-list was barely active.

My whole selfhosted mess is built around Apache. It was what I started with and I haven't run into any edge cases that it can't cover.
Exactly the same for me! I could switch to Nginx, it's one prompt away probably, but why?
> I thought it's mostly nginx or other solutions at this point.

What advantage(s) does nginx have over Apache?

Back in the day (Apache 2.0) there was certainly a performance with nginx being event-driver, but with Apache 2.4 and mpm_event, does that still apply?

* https://httpd.apache.org/docs/2.4/mod/event.html

nginx is easier to configure.
Probably depends on what one you learned first. I learned Apache first, around 1995 - 96. Nginx felt "weird" to me, though I do prefer it now.
Hard disagree, for me Apache's rule sets which look a bit like XML but predate XML by several years, are easier to read, understand and maintain.
definitely not for me. Think I had a dozen tutorial examples open for simply configuring nginx to server matrix chat to the web, ended up in crazy nginx docs, things not working properly.

Copy and pasting got things to work eventually - but my next matrix install had a similar loop where I learned about some gotchas and 'dont do this thing!' stuff with nginx.

I tried caddy instead at some point which seemed like a nicer / easier to read and do type of thing.. but then compatibility issues with Debian + Matrix + Caddy just became another time sink.

apache things would of been easier for me if the matrix tutorials including it. then some nginx updates and other things - I would not call it easier to configure.

definitely some nice things in there though - loved seeing the power of how it can work and it makes sense. It may be worth it, but not easier I feel.

Not if you've been using Apache for 20+ years...
For starters it doesn't have a Critical RCE Vulnerability.
s/a/a\ known
For sta knownrters it doesn't have a Critical RCE Vulnerability.
Whoops :)
you've missed a number of other 'a's :)
Without the "g" option, the "s" command is only addressing the first match.
I just set up an Apache a couple days ago. I had an old PHP site that used mod_auth_cas, and I needed to migrate to OIDC. The site was running on Nginx, but Nginx's OIDC module only works on Nginx+. There's a free OIDC module for Apache, so I switched. Wasn't hard.

Also, Nginx's maintainers are weird about standards. e.g., last time I checked, tabs in header field line whitespace were rejected by the Nginx parser, even though the RFC says to allow it. The maintainers at the time didn't care and wouldn't fix, reasoning that Nginx had been behaving this way for so long that anything sending tabs in header field lines would have stopped by now. I don't love that attitude.

Apache is way better in this regard. (Though I think Nginx may have cleaned up its act recently?)

Apache has mod_md -- an acme client, which lets you obtain https certificates as easily as on caddy, without integrating with awkward separate programs.

https://httpd.apache.org/docs/trunk/mod/mod_md.html

That's interesting, I use a short bash script that shuts down apache, calls certbot (which starts apache just to get the certificates) then it restarts apache once certbot is done. This way, the certs are in the standard /etc/letsencrypt location in case I ever do switch web servers. I've run Apache since the 1990's so not likely but I like to keep concerns separated. It's still nice that there is an apache mod for it though.
There is a 7 year difference between those release announcements. Personally I've never liked nginx because of their attempts at monetising it, a lot of features are behind nginx plus which is really expensive and full of sales staff who try to reach out all the time, and when you start it, it says something along the lines of "Starting a high performance webserver" which always seemed strange
Why would I not use apache if everything already works with it for me?
At work we use Apache because of mod_shib. We have yet to try nginx-http-shibboleth.
One should stop using SAML anyway as that has its own collection of problems. We learned a lot about problems with cryptographic protocols in the last 30 years that cannot be fixed in SAML.
Yeah, I wish we would, but I have no say here.
Default Wordpress docker image uses it.
MediaWiki also has it as a dependency OOTB.
I am the same way. I use Caddy if I can. But I have a lot of docker containers running apache and nginx. You probably might too.
apache comes standard on EL systems and I've never had a reason to replace it for what I do...