For a secure web server is FreeBSD with the httpd running in jail safer than using OpenBSD? reddit / freebsd ---------------------------------------------------------------------- kyleW_ne · 2020-10-07 20:32 I am looking at hosting my own publicly facing web server and maybe mail server in early 2021 taking advantage of my works ability to freely locate your own collocated server in their DC (Just waiting on my 90 day new hire probation to expire). My question is I am torn between using FreeBSD or OpenBSD. I run FreeBSD on my workstation at home and it makes a great desktop with ZFS and everything but that computer is not publicly facing. I am trying to learn more about OpenBSD and frequent it's sub but it lacks ZFS and is less performant. Which would you recommend? ---------------------------------------------------------------------- fnoyanisi · 2020-10-07 20:35 I think when it comes to security, there are lots of inputs, just a comparison of the OS is not conclusive ---------------------------------------------------------------------- freebsd_guy · 2020-10-07 20:37 If you run a firewall and only open the required ports I doubt there is really much difference. Just use the the OS that makes most sense and you are comfortable with. ---------------------------------------------------------------------- kyleW_ne · 2020-10-07 20:40 That is fair, what else should I consider? Maybe the web server being used? ---------------------------------------------------------------------- fnoyanisi · 2020-10-07 20:44 I have a couple of jails with an nginx reverse proxy to route the traffic to the right jail, and I have no issues as far as the security is concerned. The servers are mostly sitting idle though (I do not run google.com in the end). To me, if you have the latest security patches applied and you keep your stack clean & simple, which both FreeBSD and OpenBSD would let you do so, you should be good to go. It comes down to your preference and familiarity with the OS. ---------------------------------------------------------------------- AlarmDozer · 2020-10-07 21:00 I would recommend FreeBSD with ZFS for file integrity, and there is a way to link in jails with ZFS. Jails aren’t 1:1 with chroot; jails have more features, but IIRC, OpenBSD will only chroot it. ---------------------------------------------------------------------- kyleW_ne · 2020-10-07 21:13 Thank you very much. I don't have much experience with jails. I know of them and that is about it. Eager to learn more though. ---------------------------------------------------------------------- 8fingerlouie · 2020-10-07 21:56 Of course there’s a difference between running a service in a jail vs running on “bare metal”. If you run all your services in different jails with a nginx jail in front, then depending on where you find a way in, you will only have access to that jails resources. If you have access to the host machine, you’re basically just one wrong file permission away from somebody owning the entire machine. That being said, chances of finding a vulnerability in nginx rather than I.e. nextcloud are very small, and the data someone wants will be in nextcloud anyway. So jails will help limit what a potential attacker can access, but will probably not keep them out entirely. Jails are no excuse to be lazy with patching though. ---------------------------------------------------------------------- alekseytheslav · 2020-10-07 22:08 it is better to check for vulnerabilities that php software that you will run on your ngnx or apache. otherwise, try to keep the operating system and ports up to date, you can read best practices on the Internet, but usually this is enough ---------------------------------------------------------------------- fnoyanisi · 2020-10-07 22:08 I use nginx because I found out it requires less resources than Apache (my experience - may be different for you). ---------------------------------------------------------------------- desnudopenguino · 2020-10-07 22:44 OpenBSD has vmm/vmd and chroots as well. Iirc, most service daemons are chrooted by default with OpenBSD. A virtual system will usually be more secure than running the service on the base, at least in that an intruder won't get full access to the entire system. ---------------------------------------------------------------------- gumnos · 2020-10-08 00:14 If you're using the stock `httpd` web server, I believe it also has `pledge` and `unveil` to also reduce the attack surface. But jails do offer you other benefits such as VNET networking so you can use `pf` to more tightly control how jails can talk to each other. I use both FreeBSD with `nginx` and OpenBSD with the stock `httpd` and both seem to work well enough for most of my needs. The one biggest show-stopper I've found is that `httpd` only does static files and FastCGI (and traditional CGI via the `slowcgi` FastCGI coprocess), not WSGI which is what a lot of frameworks expect. So you should check what you plan to deploy to see if it works with FastCGI. I do like the homogeneous feel to OpenBSD with `httpd`, `acme-client` and possibly `relayd` all playing nicely together (and `httpd`/`acme- client` playing well with `opensmtpd` for mail), each with elegant config files (glares at Apache). If you're not using stock OpenBSD `httpd`/`acme-client`, the pendulum swings more strongly toward FreeBSD+jails. As mentioned elsewhere in replies, I also like that ZFS protects my data in ways that OpenBSD's FFS/FFS2 can't (check-summing, transparent & automatic compression, encryption whether GELI or new ZFS encryption, snapshots/clones/rollback/boot-environments). ---------------------------------------------------------------------- dlangille · 2020-10-08 00:24 If you're already using FreeBSD at home, use FreeBSD on the new server too. Take it slow. Try a non-jailed webserver first, then try a jailed webserver. Work it along as you need to. ---------------------------------------------------------------------- tofazzz · 2020-10-08 02:29 I would go with whatever you have the most familiarity with. I personally use FreeBSD and jails when I have to separate services and they work great (I use BasilleBSD). ---------------------------------------------------------------------- darkempath · 2020-10-08 04:08 >what else should I consider? What are the risks? I mean, provided you have a bland webserver setup and you ensure everything is up to date, then you're pretty secure, regardless of jails or OpenBSD. I've been running an Apache webserver on FreeBSD, without jails, since 2004 and have never had an issue. But I'm also not much of a target. My site was originally so I could teach myself BSD, but is now my mail server, web server, cloud server, etc. My daily security run output email lists hundreds of bot cracking attempts at gaining access to my system, but they're just looking for low hanging fruit and have never been successful. Don't use lazy passwords, don't enable remote root login, etc and you're fine. Most of the defaults on FreeBSD are just as fine as the OpenBSD defaults. Don't get hung up on performance, either. You'll have people telling you Apache or NginX or FreeBSD or whatever delivers better performance. If you're setting up a personal server for personal use, they'll ALL perform just fine. "Performance" should be considered if you expect your server to have a significant load, or specific types of load, otherwise there's negligible difference. Use what you're comfortable with, or use what you want to learn. Jails are fine, but they don't contribute a lot in smaller hobbyist situations. OpenBSD is technically more secure (the best kind of secure) but in practice it's not going to save you from yourself. I personally prefer FreeBSD, since it's easier to manage and I find it more flexible, but go for OpenBSD if that's what you want to learn. The worse case is you wipe it after a couple of months and install FreeBSD! ---------------------------------------------------------------------- darkempath · 2020-10-08 04:16 That's where I am! I've been running a FreeBSD webserver since 2004, and always intended to learn jails, but never got around to it and never had issues without them. ¯\\\_(ツ)\_/¯ ---------------------------------------------------------------------- kraileth · 2020-10-08 04:21 If you like ZFS go with FreeBSD. It's as easy as that. OpenBSD unfortunately has nothing to offer in regard to modern-day filesystems. It has a lot to offer in regard to security-related features, though. If you are into ZFS as well as really into security - give HardenedBSD a try (it's a hardened Fork of FreeBSD that implements a ton of additional mitigations and things like that). There's a [comparison](https://hardenedbsd.org/content/easy-feature- comparison) with FreeBSD, OpenBSD and NetBSD on their site in case you want to take a look. HardenedBSD is very similar to FreeBSD but you might want to learn additional programs like `secadm`. You also lose the ability to use `freebsd-update` (updating works different as there are no delta-based upgrades available). If you're new to jails and you plan to do things right: Do a fair bit of reading before making any decisions. Then start experimenting and challenge these decisions. It's easy to pick the most popular jails manager and just stick with it since it "seems to work well". This is why a lot of people still use `ezjail`. It has been a pioneer once but today most other options will offer more features that you will want to make use of for today's workflows. My recommendation would be to check out at least tow of them. You might want to go with `iocage` if you need to make a quick choice. It's actively developed, there's a lot of documentation available and it's probably the most popular one today. If you have a bit more time, make sure to also look at `cbsd`. Cbsd is not just a jails manager but rather a virtualization framework (it can manage Bhyve VMs, XEN and to some extend VirtualBox, too - all with consistent commands!). It offers *a lot* of options in the advanced section and it has these extremely nice dialog-based TUI which means that you'll be creating jails in no time without having to read too much on which command line arguments you'll need. Have fun on your adventure! Jails are a great technology - you'll never want to miss them again after you started using them. ---------------------------------------------------------------------- darkempath · 2020-10-08 04:24 >If you have access to the host machine, you’re basically just one wrong file permission away from somebody owning the entire machine. And on a machine that handles the personal information of lots of people, limiting the potential damage/loss makes sense. But since the server appears to be a personal web/mail server, any wrong permission anywhere will expose the personal information of the only user regardless of jails. Jails are great, but the added complexity they introduce doesn't have the same benefits on a system used by only one or two people. ---------------------------------------------------------------------- kyleW_ne · 2020-10-08 04:34 Thanks! In my downtime today I did read about ezjail but I will for sure investigate the other ones! ---------------------------------------------------------------------- kyleW_ne · 2020-10-08 04:37 > The worse case is you wipe it after a couple of months and install FreeBSD! Yeah maybe I'm making too big a deal out of it. The worst thing that can happen is I wipe it and start over. Restore my website from backups and that would be that. ---------------------------------------------------------------------- bigtreeman_ · 2020-10-08 05:39 I am back to using OpenBSD. Their claim - ***Only two remote holes in the default install, in a heck of a long time!*** note: default install, when you add packages security is possibly compromised, depending on the security of those extra packages. As mentioned by [alekseytheslav](https://www.reddit.com/user/alekseytheslav/), php, which has historically suffered exploits, etc. But, you can run a secure web server with a default install, no added packages. I would recommend Openbsd default, simple, safe, basic web content. Ask the same question on reddit - openbsd. ---------------------------------------------------------------------- Xzenor · 2020-10-08 05:42 Nginx does have a smaller footprint than apache. This actually is something to consider. You're right about the performance though. It starts to matter if you have a very popular website, and even then there are still more than enough things to tune to get more performance out of your webservice. ---------------------------------------------------------------------- Xzenor · 2020-10-08 05:43 It's more secure to run the operating system that you know, than an operating system that you don't know. Their both as secure as the owner makes it. ---------------------------------------------------------------------- darkempath · 2020-10-08 06:10 >Nginx does have a smaller footprint than apache. This actually is something to consider. Hmm, I guess it might be important in extreme situations. But Apache runs fine on a small SD in a Raspberry Pi, so I wouldn't get too stressed over footprints. I'm running Apache and postfix/dovecot on a RPI3 on an 8GB SD card just fine now, and I never bothered considering the footprint. The OP didn't give us a lot to go on, other than ***implying*** the server will run a personal website, handle personal mail, and potentially act as a learning platform. Virtually any hardware less than 15 years old will do that without breaking a sweat or worrying about webserver footprints. I still think I gave the correct advice. The OP shouldn't get hung up on performance, or footprints, or even which webserver handles static vs dynamic pages better. Unless there is significant load, the OP won't notice any difference. ---------------------------------------------------------------------- 8fingerlouie · 2020-10-08 06:42 I know my personal server is probably not what most people run at home, but I keep most services in their own jail, with nginx in front in its own jail. The server itself runs no services besides ssh and the jails. All jail storage is mounted over kerberized NFSv4 through the firewall (Server sits on a DMZ network) with rate limiting on krb5. That means that each jail can only access to information I intended. Even if you make it to root you still cannot read shares that you don’t have a token for. If you escape the jail and manage to get root, you can of course become whatever user in whichever jail you like, but I consider that a small risk. But then again, I’m paranoid. ---------------------------------------------------------------------- Xzenor · 2020-10-08 07:05 Sorry, I meant the memory footprint. But you probably won't notice the difference in a small personal envirnoment. So yeah, I agree, you definitely gave the correct advice. Sorry for adding noise to it. ---------------------------------------------------------------------- a4qbfb · 2020-10-08 12:10 That claim is extremely disingenuous. It's like a car manufacturer saying “only two of our cars have ever been involved in a fatal collision while still in the showroom”. ---------------------------------------------------------------------- hisacro · 2020-10-08 13:45 not really, "only two of ours non-heavly modified (vannila) cars have ever been involved in a fatal collision while in a crazy highway" ---------------------------------------------------------------------- a4qbfb · 2020-10-08 15:17 “default install” doesn't mean “not modified”, it means “no additional services installed or enabled”. They had an RCE in ftpd once and refused to publish an advisory or change the text on their website (back when it still said zero) because ftpd was not enabled out of the box. ---------------------------------------------------------------------- teksimian · 2020-10-08 16:22 I wanted openbsd but chose freebsd for jails And slim jails at that. No extra executables or libraries. Just enough to run nginx in one jail, php-fpm in another and SQL in a third ---------------------------------------------------------------------- bigtreeman_ · 2020-10-08 23:43 that's on their web page, not extremely disingenuous, it's like saying this is how it is. It's like saying we can only fix our Cathedral code, once you go out into the Bazaar you are open to code developed by XYZ. ---------------------------------------------------------------------- a4qbfb · 2020-10-09 11:56 I know it's on their website, and it _is_ disingenuous. See for instance the ftpd issue mentioned [here](https://www.reddit.com/r/free bsd/comments/j6yssl/for_a_secure_web_server_is_freebsd_with_the_httpd/ g8465da/). ---------------------------------------------------------------------- Yaazkal · 2020-10-09 14:53 Any of those OS are good choice. You are not telling us if you will host a static site (just http files), an app or a CMS. Anyway you will have to configure firewall, some kind of web filtering, constantly update the app/CMS etc... so security for me it's more a process than a one time installation. If you will host a CMS, that will be the main concern and actually not the OS. If you want to try jails I think you will be fine trying Bastille (jail manager) for its simplicity and becuase it support templates for jails: [https://bastillebsd.org](https://bastillebsd.org) I recommend to use it with ZFS because it will make your life easier. Jails performance it's pretty great. Also the upgrade process it's pretty easy with jails (bastille), not to mention the drawback ability that you can have using ZFS snapshots (even for the OS using beadm) If you plan for an email server later on, jails also makes sense: one jail for httpd or nginx or whatever and another jail for mail server. Also you can get more out of the same server guessing it will be idle most of the time like the majority of http servers. You can always increase the security layer using external services (sometimes free) like cloudflare (now your http server will be idle most of the time). Best of the lucks ! ---------------------------------------------------------------------- dvogit · 2020-10-13 04:42 It really depends on how much you can secure your system, but if you want the features of FreeBSD with the security, I would recommend hardenedBSD. ---------------------------------------------------------------------- kyleW_ne · 2020-10-13 05:12 I've been to their page before and read a little bit about it. Is hardened a full feature OS that is suitable for production or is it more of a research project? Maybe I should poke around in their forums? ---------------------------------------------------------------------- ManuelRodriguez331 · 2020-10-14 07:03 If the end user is confronted with the objective to set up a secure webserver he can decide for a stable distribution. Both, FreeBSD and OpenBSD have a stable branch as well and this is the recommended choice to run a production system. If the stable branch was selected by the end user, this is equal to run a managed server. That means, that the distribution is in charge to monitor and fix potential security risks. For example, not all bugfixes in the upstream are merged into the stable branch. A potential approach to investigate if the distribution is managed quite well a look on the website make sense. Is the distribution using a CVE tracker? Are the package maintainers trustworthy? Is a mailing list available?