Skip to content

Commit 5cf0e3e

Browse files
author
Ben Stern
committed
Fixed index issues that I caused
Fixed headings so the toc looks better
1 parent c892cae commit 5cf0e3e

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

.vuepress/docs-sidebar.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ module.exports = [
5555
'installation/docker',
5656
'installation/synology',
5757
{ title: 'Security',
58-
path: 'installation/security',
58+
path: '/docs/installation/security',
5959
children: [
6060
'installation/reverse-proxy-nginx',
6161
'installation/reverse-proxy-apache',
6262
'installation/reverse-proxy-synology'
6363
]
6464
}
65-
['installation/reverse-proxy', 'Reverse Proxy']
6665
]
6766
},
6867
{

installation/reverse-proxy-apache.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ layout: documentation
33
title: Apache Reverse Proxy
44
---
55

6+
# Apache Reverse Proxy
7+
68
These are the steps required to use [**Apache 2.4**](https://www.apache.org/), a HTTP server, although you can use [**NGINX**](reverse-proxy-nginx) server or any other HTTP server which supports reverse proxying. If you are familiar with Apache/basic reverse proxy config and are only interested in OpenHAB specific caveats/directives skip to [OpenHAB settings](#openhab-specific-settings)
79

810
[[toc]]
911

10-
# Installation
12+
## Installation
1113

1214
Apache runs as a service in most Linux distributions, installation should be as simple as:
1315

@@ -28,7 +30,7 @@ for Fedora/CentOS/Red Hat Enterprise
2830

2931
Once installed, you can test to see if the service is running correctly by going to `http://mydomain_or_myip`, you should see the apache2 default page.
3032

31-
# Basic Configuration
33+
## Basic Configuration
3234

3335
::: warning Security Warning
3436
It is not recommended to expose solely the configuration below to the internet.
@@ -56,11 +58,11 @@ If this doesn't fit for you, you just have to replace `localhost` with your open
5658

5759
The command `apachectl configtest` can be used to verify any config you write. To enable your new website `a2ensite <config file name>`. Once enabled, you will not have to enable your website again. Configuration can be reloaded with `systemctl reload apache2`. Please make sure to reload and clear browser cookies after every change.
5860

59-
# Authentication
61+
## Authentication
6062

6163
Authentication is recommended for additional security. There are many ways to authenticate to a proxy, but basic auth is sufficient **as long as it is over https**. Note the below documentation about [OpenHAB specific auth headers](#authentication-headers).
6264

63-
## Adding or Removing users
65+
### Adding or Removing users
6466

6567
To add users to your reverse proxy, you must use following command. Use the `-c` modifier only for your first user. It will create a new password file. **Do not** use the `-c` modifier again as this will remove all previously created users. Don't forget to change _username_ to something meaningful!
6668

@@ -78,7 +80,7 @@ and to delete an existing user:
7880
sudo htpasswd -D /etc/apache2/.htpasswd username
7981
```
8082

81-
## Basic Auth
83+
### Basic Auth
8284

8385
The below directives set the auth type to basic, set the auth name, point to our credentials file, and require a user to be authenticated before allowing them to access OpenHAB
8486

@@ -91,7 +93,7 @@ The below directives set the auth type to basic, set the auth name, point to our
9193
</Location>
9294
```
9395

94-
# Encryption/HTTPS
96+
## Encryption/HTTPS
9597

9698
In the interest of not duplicating documentation, please see the [nginx encryption documentation](reverse-proxy-nginx#enabling-https) for certificate generation options. The certificate directives for Apache are:
9799

@@ -103,11 +105,11 @@ SSLCertificateKeyFile /path/to/key
103105

104106
For more details, read the [apache mod_ssl docs](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslcertificatefile)
105107

106-
# OpenHAB Specific Settings
108+
## OpenHAB Specific Settings
107109

108110
These settings are required due to the quirks and features of proxies and/or OpenHAB.
109111

110-
## Authentication Headers
112+
### Authentication Headers
111113

112114
If you use authentication with your reverse proxy, the following two directives are necessary in OpenHAB 3.0 and later.
113115

@@ -119,7 +121,7 @@ This ensures that OpenHAB uses an alternative auth header, so it does not confli
119121

120122
This ensures that your proxy does not send your proxy authentication credentials to OpenHAB, interfering with login (and potentially sending them in plain text across a network).
121123

122-
# Putting it All Together
124+
## Putting it All Together
123125

124126
Below is a minimal configuration for a reverse proxy that listens for https requests only, uses basic auth, and proxies to 8080 (default OpenHAB http port).
125127

installation/reverse-proxy-nginx.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ layout: documentation
33
title: NGINX Reverse Proxy
44
---
55

6+
# NGINX Reverse Proxy
67

78
These are the steps required to use [**NGINX**](https://nginx.org), a lightweight HTTP server, although you can use [**Apache**](reverse-proxy-apache) server or any other HTTP server which supports reverse proxying.
89

910
[[toc]]
1011

11-
# Installation
12+
## Installation
1213

1314
NGINX runs as a service in most Linux distributions, installation should be as simple as:
1415

@@ -19,7 +20,7 @@ sudo apt-get update && sudo apt-get install nginx
1920
Once installed, you can test to see if the service is running correctly by going to `http://mydomain_or_myip`, you should see the default "Welcome to nginx" page.
2021
If you don't, you may need to check your firewall or ports and check if port 80 (and 443 for HTTPS later) is not blocked and that services can use it.
2122

22-
# Basic Configuration
23+
## Basic Configuration
2324

2425
NGINX configures the server when it starts up based on configuration files.
2526
The location of the default setup is `/etc/nginx/sites-enabled/default`. To allow NGINX to proxy openHAB, you need to change this file (make a backup of it in a different folder first).
@@ -72,12 +73,12 @@ sudo service nginx restart
7273

7374
...and then go to `http://mydomain_or_myip` to see your openHAB server.
7475

75-
# Authentication
76+
## Authentication
7677

7778
For further security, you may wish to ask for a **username and password** before users have access to openHAB.
7879
This is fairly simple in NGINX once you have the reverse proxy setup, you just need to provide the server with a basic authentication user file.
7980

80-
## Adding or Removing users
81+
### Adding or Removing users
8182

8283
You will be using _htpasswd_ to generate a username/password file, this utility can be found in the apache2-utils package:
8384

@@ -103,7 +104,7 @@ sudo htpasswd -D /etc/nginx/.htpasswd username
103104

104105
Once again, any changes you make to these files **must be followed with restarting the NGINX service** otherwise no changes will be made.
105106

106-
## Referencing the File in the NGINX Configuration
107+
### Referencing the File in the NGINX Configuration
107108

108109
Now the configuration file (`/etc/nginx/sites-enabled/openhab`) needs to be edited to use this password.
109110
Open the configuration file and **add** the following lines underneath the proxy_* settings:
@@ -113,7 +114,7 @@ Open the configuration file and **add** the following lines underneath the proxy
113114
auth_basic_user_file /etc/nginx/.htpasswd;
114115
```
115116

116-
## Add authorization and cookie directives in NGINX Configuration
117+
### Add authorization and cookie directives in NGINX Configuration
117118

118119
This is an important new requirement in openHAB 3.0 and later versions.
119120
This is not required prior to openHAB 3.0. You must add the following two directives underneath the `add_header` (in the `server` block) and `proxy_set_header` (in the `location /` block) items respectively:
@@ -125,12 +126,12 @@ This is not required prior to openHAB 3.0. You must add the following two direct
125126

126127
Once done, **test and restart your NGINX service** and authentication should now be enabled on your server!
127128

128-
## Use a client certificate based authentication
129+
### Use a client certificate based authentication
129130

130131
You can find a short tutorial in the community forum on how to do so.
131132
[Using NGINX Reverse Proxy for client certificate authentication](https://community.openhab.org/t/using-nginx-reverse-proxy-for-client-certificate-authentication-start-discussion/43064)
132133

133-
## Making Exceptions for Specific IP addresses
134+
### Making Exceptions for Specific IP addresses
134135

135136
It is often desirable to allow specific IPs (e.g. the local network) to access openHAB without needing to prompt for a password or to block everyone else entirely.
136137
In these cases NGINX can use the `satisfy any` directive followed by `allow` and `deny` lines to make these exceptions.
@@ -146,7 +147,7 @@ These lines are placed in the `location{}` block. For example, by adding the lin
146147
NGINX will allow anyone within the 192.168.0.0/24 range **and** the localhost to connect without a password.
147148
If you have setup a password following the previous section, then the rest will be prompted for a password for access.
148149

149-
# Setting up a Domain
150+
## Setting up a Domain
150151

151152
To generate a trusted certificate, you need to own a domain. To acquire your own domain, you can use one of the following methods:
152153

@@ -156,15 +157,15 @@ To generate a trusted certificate, you need to own a domain. To acquire your own
156157
| Obtaining a free domain | [FreeNom](https://www.freenom.com) | Setup is the same as above. |
157158
| Using a "Dynamic DNS" service | [No-IP](https://www.noip.com), [Dyn](https://www.dyn.com/dns), [FreeDNS](https://freedns.afraid.org) | Uses a client to automatically update your IP to a domain of you choice, some Dynamic DNS services (like FreeDNS) offer a free domain too. |
158159

159-
# Enabling HTTPS
160+
## Enabling HTTPS
160161

161162
Encrypting the communication between client and the server is important because it protects against eavesdropping and possible forgery.
162163
The following options are available depending if you have a valid domain:
163164

164165
If you have a **valid domain and can change the DNS** to point towards your IP, follow the [instructions for Let's Encrypt](#using-lets-encrypt-to-generate-trusted-certificates).
165166
If you need to use an internal or external IP to connect to openHAB, follow the [instructions for OpenSSL](#using-openssl-to-generate-self-signed-certificates).
166167

167-
## Using OpenSSL to Generate Self-Signed Certificates
168+
### Using OpenSSL to Generate Self-Signed Certificates
168169

169170
OpenSSL is also packaged for most Linux distributions, installing it should be as simple as:
170171

@@ -187,15 +188,15 @@ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/openha
187188
You will be prompted for some information which you will need to fill out for the certificate, when it asks for a **Common Name**, you may enter your IP Address:
188189
Common Name (e.g. server FQDN or YOUR name) []: xx.xx.xx.xx
189190

190-
## Using Let's Encrypt to Generate Trusted Certificates
191+
### Using Let's Encrypt to Generate Trusted Certificates
191192

192193
::: tip
193194
Skip this step if you have no domain name or have already followed the instructions for OpenSSL
194195
:::
195196

196197
Let's Encrypt is a service that allows anyone with a valid domain to automatically generate a trusted certificate, these certificates are usually accepted by a browser without any warnings.
197198

198-
### Setting up the NGINX Proxy Server to Handle the Certificate Generation Procedure
199+
#### Setting up the NGINX Proxy Server to Handle the Certificate Generation Procedure
199200

200201
Let's Encrypt needs to validate that the server has control of the domain.
201202
The simplest way of doing this is using a **webroot plugin** to place a file on the server, and then access it using a specific url: _/.well-known/acme-challenge_.
@@ -215,7 +216,7 @@ Next add the new location parameter to your NGINX config, this should be **place
215216
}
216217
```
217218

218-
### Using Certbot
219+
#### Using Certbot
219220

220221
Certbot is a tool which simplifies the process of obtaining secure certificates.
221222
The tool may not be packaged for some Linux distributions so installation instructions may vary, check out [their website](https://certbot.eff.org/) and follow the instructions **using the webroot mode**.
@@ -225,7 +226,7 @@ Don't forget to change the example domain to your own! An example of a valid cer
225226
sudo certbot certonly --webroot -w /var/www/mydomain -d mydomain
226227
```
227228

228-
## Adding the Certificates to Your Proxy Server
229+
### Adding the Certificates to Your Proxy Server
229230

230231
If you followed one of the two guides for OpenSSL or Let's Encrypt above, the certificate and key should have been placed in `/etc/letsencrypt/live/mydomain_or_myip/` or `/etc/ssl/` respectively.
231232
NGINX needs to be told where these files are and then enable the reverse proxy to direct HTTPS traffic, using Strict Transport Security to prevent man-in-the-middle attacks.
@@ -242,7 +243,7 @@ In the NGINX configuration, place one of the following underneath your server_na
242243
add_header Strict-Transport-Security "max-age=31536000";
243244
```
244245

245-
## Setting Your NGINX Server to Listen to the HTTPS Port
246+
### Setting Your NGINX Server to Listen to the HTTPS Port
246247

247248
Regardless of the option you choose, make sure you change the port to listen in on HTTPS traffic.
248249

@@ -255,7 +256,7 @@ You can check by going to `https://mydomain_or_myip` and confirming with your br
255256
**Let's Encrypt certificates expire within a few months** so it is important to run the updater in a cron expression (and also restart NGINX) as explained in the Certbot setup instructions.
256257
If you want to keep hold of a HTTP server for some reason, just add `listen 80;` and remove the Strict-Transport-Security line.
257258

258-
## Redirecting HTTP Traffic to HTTPS
259+
### Redirecting HTTP Traffic to HTTPS
259260

260261
You may want to redirect all HTTP traffic to HTTPS, you can do this by adding the following to the NGINX configuration.
261262
This will essentially replace the HTTP url with the HTTPS version!
@@ -279,7 +280,7 @@ server {
279280
}
280281
```
281282

282-
# Putting it All Together
283+
## Putting it All Together
283284

284285
After following all the steps on this page, you _should_ have a NGINX server configuration (`/etc/nginx/sites-enabled/openhab`) that looks like this:
285286

@@ -331,7 +332,7 @@ server {
331332
}
332333
```
333334

334-
# Additional HTTPS Security
335+
## Additional HTTPS Security
335336

336337
To test your security settings [SSL Labs](https://www.ssllabs.com/ssltest/) provides a tool for testing your domain against ideal settings (Make sure you check "Do not show the results on the boards" if you don't want your domain seen).
337338

@@ -364,7 +365,7 @@ All of these settings are customizable, but make sure you [read up on](https://n
364365
Feel free to test the new configuration again on [SSL Labs](https://www.ssllabs.com/ssltest/).
365366
If you're achieving A or A+ here, then your client-openHAB communication is very secure.
366367

367-
## Further Reading
368+
### Further Reading
368369

369370
The setup above is a suggestion for high compatibility with an A+ rating at the time of writing, however flaws in these settings (particularly the cyphers) may become known overtime.
370371
The following articles may be useful when understanding and changing these settings.

installation/reverse-proxy-synology.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: Synology DiskStation Reverse Proxy
44
---
55
[[toc]]
66

7+
# Synology DiskStation Reverse Proxy
8+
79
Synology DSM (as of 6.2) has the ability to automatically acquire certificates from Let's Encrypt and renew them every 90 days as required.
810
The majority of the configuration can be completed through the DSM GUI, but SSH access is required to implement authentication (**authentication is essential for remote access to your openHAB instance**).
911

0 commit comments

Comments
 (0)