How To SSL with nginx and version 2.1.1 or 2.2.0
Posted: 11 Sep 2015 17:21
There are probably quite a few of us out there that may not like the idea of using passwords in a site that isn't encrypted. This "How To:" will allow you to update.
First things first, you'll need to update a configuration file in the automation directory, my full path for that is: '/opt/z-way-server/automation'. The file is named 'Webserver.js' and you want to replace line with You will probably need to update this file in the future if you perform any updates to 2.1.1. All I did was comment out the original with two slashes and add the new one. I don't like modifying files without a way to revert back to the way the were. Once done, you'll need to restart z-way-server with At this point, you should no longer be able to access the z-way smarthome web page or the expert page for that manner.
The next steps will instruct you to install nginx. I got these from a couple of different web sites and was able to "monkey" around with the configuration file to get it to work as it didn't at first.
Next, create your certificate. I didn't perform this step as I already had one created. The steps should work without an issue.
Now we are going to edit the default configuration file for nginx. It's located at '/etc/nginx/sites-enabled/default'
Add this server directive, I placed it above the one that's there by default.
and finally update the default server directive, remember to update the cert names and your server name.
Now you should be able to connect to the Smarthome UI using https and with port 8085 instead of 8083.
First things first, you'll need to update a configuration file in the automation directory, my full path for that is: '/opt/z-way-server/automation'. The file is named 'Webserver.js' and you want to replace line
Code: Select all
ws = new WebServer(8083, function(req) {
Code: Select all
ws = new WebServer("127.0.0.1:8083", function(req) {
Code: Select all
sudo z-way-server restart
The next steps will instruct you to install nginx. I got these from a couple of different web sites and was able to "monkey" around with the configuration file to get it to work as it didn't at first.
Code: Select all
sudo apt-get update
sudo apt-get install nginx
Code: Select all
cd /etc/nginx
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/cert.key -out /etc/nginx/cert.crt
Code: Select all
sudo nano /etc/nginx/sites-enabled/default
Code: Select all
server {
listen 80;
return 301 https://$host:8085$request_uri;
}
Code: Select all
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
listen 8085;
server_name SERVERNAME;
ssl_certificate /etc/nginx/CERT.crt;
ssl_certificate_key /etc/nginx/CERT.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/z-way-server.access.log;
root /var/www;
index index.cgi;
# Make site accessible from http://localhost/
location / {
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-Proto $scheme;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://localhost:8083;
proxy_hide_header Access-Control-Allow-Origin;
proxy_read_timeout 90;
proxy_redirect http:// https://;
}