Skip to content

Instantly share code, notes, and snippets.

@TyrfingMjolnir
Last active January 18, 2023 21:45
Show Gist options
  • Save TyrfingMjolnir/991b1352bdf08dfe5977c4c0636f5375 to your computer and use it in GitHub Desktop.
Save TyrfingMjolnir/991b1352bdf08dfe5977c4c0636f5375 to your computer and use it in GitHub Desktop.

Want to save on which libraries are loaded into memory when executing your code? Here is a setup for server side swift utilizing Vapor and unix socket, with nginx as reverse proxy.

NginX documentation for #proxy_pass.

You may not need the port for each proxy_pass, and for most cases I assume you will have between 5 and 200 sockets for a single domain, depening on your activity and services.

There are several considerations in this way of thinking. My main purpose for doing this approach is that it's possible to bring any /node/ of the url tree down for replacement, maintenance, testing, or any other purpose.

Please note that in this setup every node is its own root node, and the purpose of the reverse proxy apart from providing SSL is to also be "mountpoints" of the URL.

Further examples here: Anatomy of a microservice

app.http.server.configuration.address = .unixDomainSocket( path: "/var/run/tld.domain.login" )
server {
listen 443;
location /login {
proxy_pass http://unix:/var/run/tld.domain.login:/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment