Maximum PC - UK (2020-01)

(Antfer) #1
certbot.eff.org) to get a free, self-renewing SSL certificate from
Let’s Encrypt to improve security. Installation on Linux is simple
and quick:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install nginx
>> If you’re using Bash in Windows 10, you need to perform a
couple of extra steps:
$ cd /etc/nginx
$ sudo nano nginx.conf
>> Add the following line beneath “user www-data;”:
master_process off;
>> Save (press Ctrl-O followed by Ctrl-X), and then issue the
following command:
$ sudo service ngnix start

4


AUTOSTART NGINX AND TEST CONNECTION
Nginx runs in the background, but while it automatically
restarts when you reboot a native Linux server, it’s not
set to do so in Windows. Once you’re happy everything’s working
to plan, you can have it autostart with Windows by issuing the
following command:
$ sudo update-rc.d nginx enable
>> To stop it autostarting in both Linux and Windows, issue a
sudo update-rc.d -f nginx disable command instead.)
>> Once installed, open a web browser, type your chosen domain
into the Address bar, and hit Enter. If all is working as it should
be, you’ll see a “Welcome to nginx!” message appear. You
should also test the connection from outside your local network—
try connecting through your phone’s cellular network or set up
and connect to your router’s guest Wi-Fi network, making sure
it’s configured to be isolated from the rest of your network.

5


INITIAL CONFIGURATION
All subsequent nginx configuration is done by editing a
single file:
$ cd /etc/nginx/sites-available/
$ sudo nano default
>> You’ll see the configuration file is text-based, and consists
of several enclosed blocks of code: server { location {} }. You’ll
need one server block per service you plan to make available
over the Internet, as well as generic ones to cover web-based
connections on ports 80 and 443. More on that later.
>> First of all, you need to add your domain name to the
configuration file—this will enable you to add the Let’s

B Encrypt SSL certificate in the next step. This is added
inside the first {server} block that’s set to listen
on port 80. Now scroll down until you find the line
reading “servername ;” which you should change to
the following:
server_name myservers.domain.com;




Obviously, substitute “myservers.domain.com”
with your subdomain or DDNS hostname.
After making changes and saving your file, test your
changes by issuing the following command:
$ sudo nginx -t
If it fails, reopen “default” in nano, and check your
syntax for any errors. Otherwise, you can now restart
the nginx service for real to apply your changes. Linux
users can issue the following command:
$ sudo systemctl reload nginx
If you’re running Bash in Windows 10, you should
use the following command instead:
©^ $ sudo service nginx restart




MI
CR


OS


OF


T,^ T


P-
LIN


K


There are several ways to set up a reverse proxy in
Windows. In most cases, however, your Windows PC is
your primary machine, and there are many good reasons
not to be using that; it’s best to keep the reverse proxy
isolated, which is why you should consider running a
virtual instance of Debian or Ubuntu. VirtualBox is perfect
for the task—just remember to set up bridged networking
to ensure the VM receives a proper IP address, so it’s seen
on your network.
If you’re determined to run nginx in Windows, there is a
Windows client, but as you’ll see from http://nginx.org/en/
docs/windows.html, it’s not as fully featured as the Linux
version. It’s also not easy to link with a Let’s Encrypt SSL
certificate. Thankfully, you can follow the tutorial using
Windows 10’s support for the Linux Bash Shell.
Type “Windows features” into the “Search” box, then
click “Turn Windows features on or off.” Scroll down and
check “Windows Subsystem for Linux,” then click “OK,”
and reboot when prompted. Next, open the Microsoft Store
to find and install Ubuntu 18.04 LTS. Once complete, click
“Launch” to initialize it, before creating a user account
when prompted. Once done, follow the rest of the tutorial.

WINDOWS REVERSE


PROXY


maximumpc.com JAN 2020 MAXIMUMPC 57

Free download pdf