3 ms·
Static hosting on VPS cite is easy as hell. Get a VPS with Ubuntu 22.04 for as low as 3 Euros/Month, execute the following commands: ``` sudo apt-get install
by triknomeister 4y ago
Static hosting on VPS cite is easy as hell. Get a VPS with Ubuntu 22.04 for as low as 3 Euros/Month, execute the following commands:
```
sudo apt-get install -y nginx python3-certbot-nginx certbot
sudo ufw allow "Nginx Full"
sudo unlink /etc/nginx/sites-enabled/default
sudo mkdir -p /srv/https/website
sudo chown -vR $MYUSER:$MYUSER /srv/https/website
echo "I've created my website here." > /srv/https/website/index.html
cat > conf <<- EOM
server {
listen 80;
listen [::]:80;
root /srv/https/website;
index index.html;
server_name $URL;
location / {
try_files \$uri \$uri/ =404;
}
}
EOM
sudo cp config /etc/nginx/sites-available/website
sudo ln -s /etc/nginx/sites-available/website /etc/nginx/sites-enabled/website
sudo certbot --nginx -n -d $URL --agree-tos --redirect -m $EMAIL --webroot -w /srv/https/website
```
Setup your DNS to the IP of VPS and you're done setting up your static website. Updates now are just `rsync`
- lucideer 4y agoThis is great but what the article is about that you're underestimating is the decision anxiety and subsequent complexity of arriving at the specific configuration you've posted. Even after you've for some reason decided on which tech to use (nginx, etc.), it doesn't set itself up (well it does but not in as easy-to-use config as yours). Examples of how to configure it well are going to vary depending on where you read - your example is unique, which should one follow. Or if you want to create your own config from scratch reading docs, I'm sure your configuration is the product of many hours of trial and error and a bit of debugging. --- As an aside, for anyone reading this who is looking for a good static hosting setup, this is a great one.
- prmoustache 4y ago> This is great but what the article is about that you're underestimating is the decision anxiety and subsequent complexity of arriving at the specific configuration you've posted. The same can be said about finding your static site generator, your favorite social media, the color of your car, your home deco, the race of your next dog... If you want a life where people do the choices for you and stuff edibles into your mouth, there is one easy solution: a nursing home.
- lucideer 4y agoThat's fair but... - SSGs do have some of the same problems as mentioned in the articles. Selection could be easier. - Social media is mostly selected based on networks, so that's not as relevant here. - Colour of your car, home deco.... "race"? of your next dog are subjective/aesthetic and not as functionally imperative. So not quite so comparable. Taking your car analogy and looking at selecting - say - the model of car, this is much easier. They're broadly arranged into obvious well-understand functional categories, and unless you're a dedicated car nut who WANTS to invest time & energy into customisation, they generally are drivable and function well straight out of the lot. Much easier to set up than a static host or SSG.
- Uehreka 4y agoYeah but what about SSL? You’ll need a handful of more lines of nginx, plus a script that runs once a month or so to get a new LetsEncrypt cert. Supposing that script you write or copy/paste works, now you’re good. Until your site gets mentioned on HN or other social media. If you are in fact using a 3 euro/month VPS you’re almost certainly sharing 1-2 CPU cores with some other colocated VPSes. If your site gets a sudden surge in demand (and particularly if you have any images or video on your site) you’re either going to get hugged to death, or worse, people will complain that your site loads slowly and accuse you of writing too much JS. My recommendation is to use Github/GitLab pages with a free Cloudflare in front for caching and SSL. That’s the setup I use for my site (https://chrisuehlinger.com https://chrisuehlinger.com, but grumps beware: it is absolutely soaked in JS). It’s free/month, doesn’t require moving parts like a manually rolled LetsEncrypt bot, and holds up when my site gets traffic.
- 10000truths 4y ago> Yeah but what about SSL? You’ll need a handful of more lines of nginx, plus a script that runs once a month or so to get a new LetsEncrypt cert. Supposing that script you write or copy/paste works, now you’re good. The setup might be a bit more involved, but nothing that can’t fit in a single Bash script. > Until your site gets mentioned on HN or other social media. If you are in fact using a 3 euro/month VPS you’re almost certainly sharing 1-2 CPU cores with some other colocated VPSes. If your site gets a sudden surge in demand (and particularly if you have any images or video on your site) you’re either going to get hugged to death, or worse, people will complain that your site loads slowly and accuse you of writing too much JS. An HN “hug of death” is a laughably small amount of traffic for a static file web server. Nginx can serve hundreds of static HTML/JS/CSS files per second even on a cheap VPS. > My recommendation is to use Github/GitLab pages with a free Cloudflare in front for caching and SSL. That’s the setup I use for my site (https://chrisuehlinger.com https://chrisuehlinger.com, but grumps beware: it is absolutely soaked in JS). It’s free/month, doesn’t require moving parts like a manually rolled LetsEncrypt bot, and holds up when my site gets traffic. I’m sure that setup works well for you, but it’s overkill for serving static files. Unless you’re a truly special case, literally everything you need can be handled in a single VPS, which is dead simple to manage and very easy to move around if needed.