Set up an NGINX server and access via Meshnet to manage your web content remotely. Our NGINX Support team is ready to assist you. 

Set up an NGINX Server and Access via Meshnet

NGINX is a fast, reliable web server that handles traffic efficiently and supports features like reverse proxy and load balancing. Meshnet creates a secure virtual network, allowing safe remote access to devices and hosted content. Together, they enable efficient and secure web hosting from anywhere.

Introduction to NGINX and Meshnet

NGINX, pronounced “engine-x,” is a high-performance open-source web server known for stability and low resource usage. To get started, you can install Nginx Web Server on Ubuntu 24.04, allowing you to efficiently serve websites, act as a reverse proxy, or balance traffic across multiple servers. When combined with Meshnet, NGINX can be securely accessed from anywhere, creating a seamless and encrypted connection between your devices over a virtual network.


Key Uses of NGINX

  • Serving Static Content: Quickly delivers HTML, CSS, JavaScript, and images for high-traffic sites.
  • Reverse Proxy: Acts as an intermediary between clients and backend servers, providing load balancing, caching, and security.
  • Load Balancer: Distributes traffic across multiple servers to optimize performance and prevent overload.
  • HTTP Cache: Stores frequently requested resources to reduce server load and improve response times.
  • Email Proxy: Supports email protocols like IMAP, POP3, and SMTP for secure email handling.

Introduction to Meshnet
Meshnet creates a secure, encrypted network connecting devices regardless of location, essentially forming a virtual LAN over the internet.

How Meshnet Enables Secure Remote Access

  • Encrypted Connections: Uses strong encryption protocols to protect data between devices.
  • Direct Device-to-Device Connectivity: Allows secure access and file sharing without routing through a central server.
  • Virtual LAN Functionality: Makes remote devices appear on the same local network, simplifying access and eliminating complex configurations.

Installing and Setting Up NGINX

Installing NGINX involves downloading, configuring, and starting the server. Steps may vary slightly depending on your operating system.

Download NGINX

  • Linux: Update your package lists and install via your package manager.
sudo apt update
sudo apt install nginx
  • Windows: Download the stable build from the official NGINX website.
  • From Source: Download the source code and compile for full customization.

Extract and Configure

  • Extract the archive (Windows or source build) to your desired folder.
  • Open the main configuration file (nginx.conf) in a text editor.
  • Set the listening port within the server block (default 80). Example:
server {
listen 8080;
server_name example.com;
}
  • For multiple websites, create separate server blocks specifying server_name and root directories.

Managing NGINX

  • Start Server:
sudo systemctl start nginx   # Linux
  • Enable Startup on Boot (Linux):
sudo systemctl enable nginx
  • Check Status:
sudo systemctl status nginx
  • Reload Configuration:
sudo systemctl reload nginx
  • Test Syntax:
sudo nginx -t
  • Firewall Configuration

Ensure the listening port is open for incoming traffic. Example on Ubuntu:

sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'Nginx HTTPS'
sudo ufw allow 8080/tcp

After completing these steps, NGINX will be installed, configured, and ready to serve your web content.

Managing NGINX on Windows with Command Prompt

Starting NGINX
First, open Command Prompt and navigate to the folder where NGINX is installed, such as C:\nginx. Then run the command to launch the server. This will start NGINX and make it ready to serve web content.

start nginx

Stopping NGINX
When you need to stop NGINX, you have two options. Use the first command for a graceful shutdown that allows active connections to finish. Use the second command to stop immediately and close all connections.
nginx -s quit
nginx -s stop

Restarting NGINX
To apply changes in your configuration, restart the server. You can reload the configuration without shutting down the server completely, or you can stop and start it again for a full restart.
nginx -s reload
nginx -s stop
start nginx

Allowing NGINX Through Windows Firewall
To ensure NGINX can accept incoming connections, configure the Windows Firewall. Open Windows Defender Firewall, create a new inbound rule for TCP, and specify the ports that NGINX is using, usually 80 for HTTP and 443 for HTTPS. Allow the connection, select the network profiles it applies to, and give the rule a clear name. Once saved, your server will be reachable from other devices.

Customizing Your NGINX Landing Page

Locate and Edit index.html
First, find the index.html file that NGINX serves. In most cases, the file is in the web root directory specified in your configuration, such as /var/www/html/index.html or /usr/share/nginx/html/index.html. On the other hand, if you have set up a virtual host, check the root directive to locate the correct folder.

Open the file using a text editor like nano or vim:

sudo nano /var/www/html/index.html

Update the content to reflect your preferred landing page. You can change text, images, styles, and add interactive elements using HTML, CSS, and JavaScript. After editing, save the file and exit the editor.

Reload NGINX to Apply Changes
After updating the file, reload NGINX so it recognizes the changes. Use one of the following commands depending on your setup:

sudo systemctl reload nginx
sudo service nginx reload
sudo nginx -s reload

Verify the Updates
Open your web browser and visit your domain or IP address. Your customized landing page should now appear. If the previous content still shows, clear your browser cache or try a different browser to ensure you see the updated page.

Accessing Your NGINX Server Remotely via Meshnet

Before You Begin
First, ensure that NordVPN is properly installed and running on both the server hosting NGINX and the device you’ll use to connect. Log in to the same Nord Account on both devices to link them through Meshnet. On both devices, enable Meshnet in the NordVPN app. On the NGINX server device, go to Profile, then Meshnet, select Manage Devices, and ensure Remote Access is enabled.

Steps to Connect

  1. Copy the Nord Name: On the NGINX server device, open the NordVPN app and find the device’s unique Nord name. Copy it.
  2. Open a Browser on the Peer Device: Use your preferred browser to connect.
  3. Enter the Nord Name and Port: In the browser’s address bar, type the copied Nord name followed by a colon and the port number your NGINX server uses, for example your-server-nordname:80.
  4. Access the Webpage: Press Enter. Your NGINX server’s webpage should now appear on the peer device.

This method creates a secure connection over Meshnet, making remote access simple and safe without complicated port forwarding or network setups.

Troubleshooting and Tips for NGINX and Meshnet

  • Port Conflicts: Ensure no other application is using the same port as NGINX. Change the listen port in nginx.conf if needed and restart NGINX.
  • Cached Pages: If your updated landing page does not appear, clear your browser cache or try a different browser to see the latest content.
  • Command Line Limitations: Commands used to start NGINX may block further input in the same terminal. Open a new terminal window to run additional NGINX commands.
  • Firewall Access: Verify that Windows Firewall or any security software allows incoming connections on the port NGINX is listening to, typically 80 or 443.
  • Remote Access Issues via Meshnet: Confirm Meshnet is enabled on both devices, Remote Access is turned on for the server, and the correct Nord name and port are used in the browser.

 Set up NGINX server and access via Meshnet

Following these steps helps maintain smooth operation and avoids common errors during setup and remote access.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Therefore, by following the steps outlined, you can easily set up an NGINX server and, as a result, access it via Meshnet, ensuring that your web content is not only efficiently served but also securely reachable from remote devices. Proper configuration, firewall settings, and Meshnet enable seamless and safe remote access.

In brief, our Support Experts demonstrated how to fix the “554 5.7.1 : Relay access denied” error.