initial commit
This commit is contained in:
42
docs/nginx/adding-nginx-site.md
Normal file
42
docs/nginx/adding-nginx-site.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Adding a new site to Nginx in Ubuntu
|
||||
|
||||
This guide assumes you already have Nginx running on your server.
|
||||
|
||||
## Add an available site configuration
|
||||
|
||||
Create a new configuration file in the `/etc/nginx/sites-available` directory. The file will usually be titled after the domain or subdomain you are adding
|
||||
|
||||
```bash
|
||||
sudo vim /etc/nginx/sites-available/example.com
|
||||
```
|
||||
|
||||
For the file contents enter a valid nginx server block configuration. Here is an example:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name example.com www.example.com;
|
||||
}
|
||||
```
|
||||
|
||||
## Add the site configuration
|
||||
|
||||
Once the configuration file is setup we can enable it by creating a symbolic link to the `sites-enabled` directory.
|
||||
|
||||
```bash
|
||||
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
|
||||
```
|
||||
|
||||
## Test and Update Nginx
|
||||
|
||||
Test the configuration file for syntax errors:
|
||||
|
||||
```bash
|
||||
sudo nginx -t
|
||||
```
|
||||
|
||||
If the test is successful, reload Nginx to apply the changes:
|
||||
|
||||
```bash
|
||||
sudo systemctl reload nginx
|
||||
```
|
29
docs/nginx/easy-reverse-proxy-config.md
Normal file
29
docs/nginx/easy-reverse-proxy-config.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Easy Reverse Proxy Config for Nginx
|
||||
|
||||
## Introduction
|
||||
|
||||
This guide will show you how to set up a reverse proxy for your web server using Nginx. A reverse proxy is a really handy tool that allows use to redirect traffic incoming to our server to a different location, for example to another web server, or to a different port.
|
||||
|
||||
I find this most useful for redirecting requests to different dockerised services, but it can be used for many other things too.
|
||||
|
||||
## Config
|
||||
|
||||
The config for a reverse proxy is really simple. Here's an example of a basic reverse proxy config:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name my-site.com
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:5000;
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This config will redirect all traffic coming to `my-site.com` to `http://localhost:5000`. This method will also easily allow you to add SSL to your services, as you can use the `certbot` tool to generate SSL certificates for your domain. Certbot will automatically configure this basic reverse proxy config to use SSL.
|
4
docs/nginx/index.md
Normal file
4
docs/nginx/index.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Nginx Snippets and Musings
|
||||
|
||||
#### [Easy Reverse Proxy Config](./easy-reverse-proxy-config.md)
|
||||
#### [Adding a Site to Nginx](./adding-nginx-site.md)
|
Reference in New Issue
Block a user