Skip to content

Instantly share code, notes, and snippets.

@sanderpick
Last active March 13, 2018 20:12
Show Gist options
  • Save sanderpick/c993b0df23f2ad638224c6c88338d35b to your computer and use it in GitHub Desktop.
Save sanderpick/c993b0df23f2ad638224c6c88338d35b to your computer and use it in GitHub Desktop.
Install an nginx reverse proxy + cache for an ipfs-cluster peer gateway on Amazon Linux.
#!/usr/bin/env bash
set -e
# install nginx
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install ./epel-release-latest-7.noarch.rpm -y
sudo yum install nginx -y
rm epel-release-latest-7.noarch.rpm
# grab config files
wget https://gist.github.com/sanderpick/bead03b36712f292a3ddcd657d6afe65/raw/41fd86915e5b6df1a9fab5220523ea6acbb25636/ipfs-gateway-nginx.conf
sudo mv ipfs-gateway-nginx.conf /etc/nginx/nginx.conf
wget https://gist.github.com/sanderpick/bead03b36712f292a3ddcd657d6afe65/raw/41fd86915e5b6df1a9fab5220523ea6acbb25636/nginx-gzip.conf
sudo mv nginx-gzip.conf /etc/nginx/conf.d/gzip.conf
# setup cache dir
sudo mkdir -p /data/nginx/cache
# fix nginx bug (https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864/comments/2)
sudo mkdir /etc/systemd/system/nginx.service.d
sudo bash -c 'printf "[Service]\nExecStartPost=/bin/sleep 0.1\nRestart=always\n" > /etc/systemd/system/nginx.service.d/override.conf'
sudo systemctl daemon-reload
# start
sudo systemctl start nginx
@sanderpick
Copy link
Author

sanderpick commented Feb 28, 2018

Usage

Run the installer

$ wget https://gist.github.com/sanderpick/c993b0df23f2ad638224c6c88338d35b/raw/555c58ffba0ee4143fb269e55269d79cfdca32a9/install.sh -v -O install.sh && bash install.sh

Sanity check

$ sudo systemctl status nginx

Tail nginx Logs

$ sudo tail -f /var/log/nginx/access.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment