Live data from Hacker News

Nginx Unit – Universal web app server

github.com

111–120 of 201 posts

Re: Nginx Unit – Universal web app server

#111
Can you feasibly run this behind nginx (either over http in a regular reverse proxy setup or with sort of more clever shared memory forwarding situation?) so you could, eg use nginx-unit instead of php-fpm but keep everything (ssl termination, rate limiting, etc) centralized behind your core nginx load balancer?

Edit: yes, it’s as straightforward as it sounds: https://unit.nginx.org/howto/integration/

Re: Nginx Unit – Universal web app server

#112
post #11

Well I commend the Nginx team for trying something new and launching this, even though I'm not sure what I would use it for personally. Slightly tangental, but it always irks me when I see these kinds of responses in JSON: { "success": "Reconfiguration done." } Really this should be something like "result": "success". Using "success" as a key name tells me nothing about the data it's representing.

That's like when I see APIs that give you responses with a 200 code, but then in the message there's a backend error.

Some people treat http as a pure transport/network layer and the actual body as the app-level layer.

In such an approach, any http-level error would be a network, server maintenance or other unknown/fatal error type of things.

App errors are encoded in the response body in a app-defined way.

It's not a completely bogus way of handling things, as long as it is perfectly consistent throughout the project and properly documented, which is rarely the case.

Re: Nginx Unit – Universal web app server

#113

Earlier quoted context omitted.

Unironically this. After trying Kubernetes, Terraform, Ansible, and various proprietary PaaS config formats, I've grown to love Compose files' simplicity.

Yes, when compared to extreme complexity, compose is simpler. But it's hardly simple.

I'll happily try anything simpler than that if you give me an idea what that might be.

Not trying to be salty or anything – I really think Compose hits the sweet spot of abstraction which is less complex than both the monstrosities I listed and the ad hoc Bash scripts copying code over SSH and restarting services approach (so, the other extremity of declarative v. imperative).

Re: Nginx Unit – Universal web app server

#114
post #11

Well I commend the Nginx team for trying something new and launching this, even though I'm not sure what I would use it for personally. Slightly tangental, but it always irks me when I see these kinds of responses in JSON: { "success": "Reconfiguration done." } Really this should be something like "result": "success". Using "success" as a key name tells me nothing about the data it's representing.

If I were designing it I’d probably have a result field too, or even a success boolean. But I don’t hate what they’re doing here: the presence of the key is the Boolean value, the value is the description. A two for one.

Re: Nginx Unit – Universal web app server

#115
post #11

Well I commend the Nginx team for trying something new and launching this, even though I'm not sure what I would use it for personally. Slightly tangental, but it always irks me when I see these kinds of responses in JSON: { "success": "Reconfiguration done." } Really this should be something like "result": "success". Using "success" as a key name tells me nothing about the data it's representing.

I rather have:

{ "responseMessage": "Reconfiguration done.", "responseCode": 133, "isSuccessful": true }

This way you can map to a custom message on your front-end based on the responseCode whether its successful or not, you can fallback to the response message if no mapping is found, and you can easily check if the transaction was successful or not.

Re: Nginx Unit – Universal web app server

#116

Earlier quoted context omitted.

In this particular example, it’s actually a whole lot worse than that, by spec at least. Excerpt from their OpenAPI schema https://github.com/nginx/unit/blob/7dd5ad93a4c147b086a8d82ec... >: jsonSuccessMessage: type: object description: "JSON message on success." additionalProperties: type: string jsonErrorMessage: type: object description: "JSON message on error." additionalProperties: type: string Yes, this is as ba…

By Serde's classification, `success: {}` is a textbook externally tagged representation.

If there was always only one top-level field and everything else was inside that, it could be externally tagged, but it’s definitely just untagged here, because #/components/examples/errorInvalidJson/value (line 4397) shows an error body with multiple top-level fields: {"error":"Invalid JSON.","detail":"…","location":{"offset":0,"line":1,"column":0}}. Externally tagged would be {"error":{"message":"Invalid JSON.","detail":"…","location":{…}}}.

Re: Nginx Unit – Universal web app server

#117
post #83

Nginx Unit + PHP seems to handedly out-perform Nginx + php-fpm[1][2][3]. Also, Docker environments running PHP via Nginx Unit will no longer need separate containers for http + fpm, as it works similar to Apache's mod_php. 1. https://habr.com/en/articles/646397/ 2. https://medium.com/@le_moment_it/nginx-unit-discover-and-ben... 3. https://github.com/nginx/unit/issues/6#issuecomment-38407362...

You don't need separate containers to run nginx and php-fpm.

does it involve running supervisor inside the container? that’s fine but it’s definitely not kosher.

in my experience those are the ones that kick and scream when they don’t start as root.

Re: Nginx Unit – Universal web app server

#119
post #75
post #72

This is an interesting idea, but I feel like it is a big oversight not to have build in support for automatically getting certificates. Instead the docs have you do something manual with certbot (a complete nono if you believe in automatic SSL and are using docker images that don't persist data, as Docker is meant to be used). The only reason I have SSL on my domain in the first place is that my host offers a simple…

> using docker images that don't persist data, as Docker is meant to be used docker volumes entered the chat

Which means now you can't do a clean deploy of a new version, you can't be sure that what works on one machine is the same as what works on another etc.

Re: Nginx Unit – Universal web app server

#120
post #106

Earlier quoted context omitted.

wait, did that continue to use php-fpm? if not I want details plz! :D (especially around the logging sync, unless it’s just php-fpm configured to collect child process output)

Yes, it did, not too much magic going on, the Go proxy also was a replacement for supervisord so it started nginx and fpm, reaped zombies and pulled all the important logs into stdout/stderr. The most remarkable thing was how this revitalized a team that wrote boring PHP software limited to deploying via FTP on PHP 5. They ended up really getting into stripping out every piece of PHP they didn't use because the image…

awesome, thank you for the details!
Post reply on HN