Skip to content

Instantly share code, notes, and snippets.

@scottopell
Last active April 18, 2020 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottopell/a73ca344a1ebad236fe40c4da23fa60c to your computer and use it in GitHub Desktop.
Save scottopell/a73ca344a1ebad236fe40c4da23fa60c to your computer and use it in GitHub Desktop.
Just random shit that I always have to look up when I'm setting up a server

No guarantees any of this is secure or the right way to do things, I'm using this 90% for

Setup Nginx

https://linode.com/docs/web-servers/nginx/use-nginx-reverse-proxy/

For certs/https: https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx

Remember to port forward 443 instead of 80

Setup Plex

https://www.linode.com/docs/applications/media-servers/install-plex-media-server-on-ubuntu-18-04/

Setup Plex behind Nginx Reverse Proxy

Css needs to be served from /web, but I wanted to be able to access plex at just <blah>.<domain>.com/plex

TODO Figure out how to make this work with https. After I enabled https, I had to host under location / {, and the shortcuts for /plex no longer worked. I got the error Unable to connect to "<PLEX_SERVER_NAME>" securely.

$ cat /etc/nginx/conf.d/plex.conf
server {
  listen 80;
  listen [::]:80;

  server_name example.com;

  location /plex {
      proxy_pass http://localhost:32400/web;
      proxy_set_header X-Real-IP $remote_addr;
  }

  location /web {
      # serve the CSS code
      proxy_pass http://localhost:32400;
  }
}

Setup ssh x forwarding

On the server

# contents of /etc/ssh/ssh_config
Host *
   ForwardAgent no
   ForwardX11 no
   ForwardX11Trusted yes

On the client

# contents of ~/.ssh/config
Host <INSERT NAME HERE>
 HostName 192.168.<INSERT IP HERE>
 ForwardX11 yes
 User <INSERT REMOTE USER HERE>

Automatically mount external disk

Edit /etc/fstab and include something like the following

/dev/disk/by-id/usb-Seagate_BUP_BK_NA7PVLK7-0:0-part2 /mnt/sgExternal auto nosuid,nodev,nofail,x-gvfs-show 0 0

Alternate gnome-disk and configure there

I found it easiest to use gnome-disk to do the initial setup, and then tweak fstabs manually to get the right directory

Note You do not have to create the directory for the mount target (eg, /mnt/sgExternal) beforehand, the system will create it for you

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