Show HN: Deploying subdomain-based routing like github.io
github.com
github.com
One would be complex rewrite rules. Another, is to use LUA with Openresty. And you dont need another node app, and you dont need the terrible performance you get with the node app, and you dont use a language meant for frontend things to do backend things.
Seriously, what is it with every node dev using node for everything???? Yes, i know when all you know is a hammer, everything is a nail, but seriously, come on. There are plenty of better languages to have done this in, all of which are more performant for this type of thing, had you still decided to not use lua/rewrites.
That's true, but only if you have access to your web server!
If you're using something like Vercel (or some other hosting service) to run your application, having a little middleware that handles subdomain routing is pretty common.
edit: Sorry if I've read this comment out of context - the linked repo has been taken down.
/srv is a standard [0] directory.
[0]: https://en.wikipedia.org/wiki/Filesystem_hierarchy_standard
Or in a shared hosting environment /home/<user>/public_html/ or /home/<user>/www/
tftp is one that is regularly served out of there.
In reality, larger software projects like nginx and apache have their own opinions and usually serve out of different places.
It might make sense if the software is serving a domain from something installed with a package. Nginx is often installed with a package and long-lived data goes into /var. So it makes sense to serve /var/www for their examples. Then people just build on those examples, sadly being unaware of or unwilling to change to values that were preinstalled for demonstrations.
But for multi-homing a server (or even a single site on that server), I still end up putting stuff under /srv/<domain>/<site>, so example might be /srv/systemd.software/www [0]. Then `/srv/<domain>` might have its own fstab entry -- for example, it might be a bind-mount to somewhere else, or it might be its own disk/encryption, or it might be a network mount.
Any admin can do what they want on their own servers. I just figure it's best to follow documented standards.
[0]: https://github.com/inetknght/systemd.software/blob/0bf207d6f...
When was the last time you hopped between distros Ubuntu->OpenSUSE->Fedora and had packages be in the same spot? Because I distro hop a LOT and they almost NEVER are.
Even if it's just /bin, /sbin, /usr/sbin, /usr/local/bin, where is the consistency, not to mention controlling access. Remember when Debian took the sbins out of the path and everybody claimed Debian sucked?
When was the last time you saw /usr mounted as read-only? Because it's supposed to be.
With tech like snaps and flatpaks, containers, NixOS, etc, to call FHS anything more than a suggestion in 2023 is extreme wishful thinking.
# auth_basic_user_file /etc/apache2/.htpasswd;
https://docs.nginx.com/nginx/admin-guide/security-controls/c...Overengineered, but i dont have to muck with auth files, and can keep it up to date from other sources
The main reason for this is to make sure your htaccess file is outside of the document root. This is horrible behavior Apache had (still has?), and is a security issue.
> However, in general, use of .htaccess files should be avoided when possible. Any configuration that you would consider putting in a .htaccess file, can just as effectively be made in a <Directory> section in your main server configuration file.
2002: https://web.archive.org/web/20020805160131/http://httpd.apac...
Present day: https://httpd.apache.org/docs/current/howto/htaccess.html#wh...
Note that more often than not I'll often argue for sticking with FHS and it's a good rule of thumb to know the rules first before you go breaking them. However in my opinion /srv isn't a pragmatic choice to make in a demonstration and it's for the sake of clarity I can see why the writer would just say /websites. In your own implementation you can put your content wherever you want.
- Security: You want the cookies to be limited to the subdomain
- SEO: You get penalized if the same content is available at two URLs, because it is assumed it's a copy
The SEO issue applies in the other direction too. When we first set this up for reddit (you could and still can go to subreddit.reddit.com), we found out that we were getting penalized for having the same content on both URLs. So we set it up to redirect the subdomain to the /r/subreddit URL since that was the canonical URL and the cookies didn't matter.
Especially love how easy it is to set up localhost subdomains and ssl.
Can you point me to an example I would love to check it out
I thinks I accidently deleted this repo.
Now it is back: https://github.com/xieyuheng/x-server
So far, feedback here are helpful to me.
Sorry about the mis-deleting.
My aim is to build a open-source mini vercel and netlify alternative.
`x-server` is just a starting point.
I have even more "evil" projects, like "using file system as database", I will leave that for another Show HN :) :) :)
Well I hope that's not all you do...
curl -H 'etc.example.com' 'https://www.example.com/shadow'
-> /etc/shadowGood on you. As a sysadmin of decades I could absolutely to this in a few lines of nginx or other web servers as others have mentioned, however this looks like a cool and fun project.
Just because doing it one way wins on some specific metrics (like performance) doesn't mean it does for other people (like node developers who want to change some server functionality).
I can't believe people can write with a straight face that a web dev should learn nginx, set up openresty and write a lua script to do this. Get out of your own bubbles people.
Edit: actually, based on the use case cited in the readme, this would be fine. I was thinking more of a website like GitHub that lets people sign up and create tenants.