Creating an Nginx Web Server on Ubuntu - jwells24/Tech-Journal GitHub Wiki
Creating an Nginx Web Server on Ubuntu\Linux
-
The first step is to ensure that your Ubuntu System has internet access and can resolve names. I had to create firewall rules that allowed TCP packets from my web server across the firewalls to my DNS server, at mgmt01. Remember to add a rule 1 established state enable to allow established connections back across to the web server.
-
Once I allow my Ubuntu Server access to my DNS server, I need to allow firewall access for my web server to go to the WAN interface and back to access the internet. This is necessary for the first command we run before downloading NGINX, which is shown below to update our installation.
- If the above command does not work, check to make sure your box has internet connectivity and is allowed to and back both the WAN interface (The web) and to your DNS server (mgmt01). The next command we run is shown below, and installs NGINX.
- Now that NGinx is installed, we need to edit the firewall rules to allow a port 80 TCP packet to go from our mgmt01 to the web server, and back. Keep in mind the NAT and port forwarding rules you have created, as these could affect source and destination addresses regarding firewall rules and where traffic is directed. Once you are all set with this, Nginx is running a default page on port 80 as soon as it is installed, so just navigate to http://web-server to access the test page.
Creating a Custom Test Page
- We have our Nginx web server running, but we need to add a custom test page to navigate to. First, cd into /var/www/html on the Web server. Remove the default .html file using sudo rm. Create a new file called index.html in the /var/www/html/ directory and use sudo to edit it. The screenshow below shows a basic, custom web page using Nginx. Add this to index.html and make sure to restart nginx, and you will have a custom web page.