NginX Proxy Manager - Reverse Proxy
NginX Proxy Manager - Reverse Proxy
Feb. 3, 2024, 10:58 p.m.
Server, Blog,
0 Comments
What Is NginX reverse proxy?
NginX, often pronounced as Engine-X, serves as a versatile web server and reverse proxy. In simple terms, it handles both the delivery of web pages and acts as a mediator for incoming web requests. While this might sound somewhat generic, its versatility is its strength. NginX can not only serve web pages but also efficiently route requests for web pages, web services, and web applications to their intended destinations. Think of it as a central hub and router for web traffic. When a request comes in for any web service, NginX takes charge and directs the request to the right place.
NginX's configuration primarily occurs through terminal commands and configuration files. Although it might not be the most visually appealing process, it isn't overly complicated. However, familiarity with the available configuration options is essential.
For those who prefer a more user-friendly approach, there's NginX Proxy Manager, a graphical user interface (GUI) that simplifies the process, sparing you the need to manually edit numerous configurations.
How Does it Work
When you wish to direct a user to a specific web page or site, NginX excels at the task. NginX listens on your server, intercepts incoming requests, and then efficiently directs each request to the appropriate service, server, page, or application.
When requests for websites reach a server via standard ports (usually 80 or 443), NginX steps in. It parses the request by name and checks its configuration files to find a match for the requested site. For example, if you request "fixitdelrio.com," NginX will seek a configuration file that specifies what to do with requests for that site. If it finds a match, it uses the configuration to route the request to the appropriate server or service. For instance, it might instruct NginX to send the request to IP address 10.20.30.40. For other sites running on the same server, like "opensourceisawesome.com," NginX routes the request to the same IP but a different port. You don't need to know the specific port because NginX handles the redirection seamlessly.
Adding SSL and Encryption through Lets Encrypt
NginX can also handle SSL and encryption, making it a valuable tool for securing your sites. Suppose you want to run "info.christopherancheta.co.nz" on HTTPS instead of HTTP. In that case, NginX can assist in configuring this change. NginX Proxy Manager simplifies the process of enforcing HTTPS, ensuring that visitors always access your site securely—a vital step in safeguarding users in today's digital landscape.
Now, let's dive into the setup process:
Installing Docker: Start by installing Docker CE (Community Edition), a lightweight virtualization tool for running applications, websites, and services. Installation instructions vary by operating system, so search for "How to Install Docker CE" and follow the relevant instructions for your OS.
Setting Up NginX Proxy Manager:
- Create a folder to hold your NginX Proxy Manager setup files. In a Linux/Unix/Mac terminal, run:
->cd nginx_proxy_manager
- Create a config.json file within this folder. You can use any text editor; here, we'll use nano:
->nano config.json
Paste the following JSON into the file, replacing "your_username" and "your_password" with your preferred username and a strong password:
- Save the config.json file and exit the text editor (CTRL+O, Enter, CTRL+X).
Creating a docker-compose.yml File:
- In the same nginx_proxy_manager folder, create a docker-compose.yml file:
--> nano docker-compose.yml
- Copy and paste the following YAML code into the docker-compose.yml file:
Adjust the placeholders 'your_username' and 'your_password' to match the values you set in the config.json file. Ensure that 'your_root_password' is a strong root password for the MySQL database.
- Save the docker-compose.yml file and exit the text editor (CTRL+O, Enter, CTRL+X).
Starting NginX Proxy Manager:
- Run the following command to fetch Docker images and start the containers:
Accessing the NginX Proxy Manager Dashboard:
- Once the containers are up and running, you can access the NginX Proxy Manager admin portal by browsing to your server's URL or IP address, followed by port 81 (e.g., http://yourserver.com:81).
Proxying Site Traffic with NginX Proxy Manager:
- To route traffic for specific sites, click on 'Proxy Hosts' in the dashboard and then 'Add Proxy Host'. Enter the domain name, server hostname or IP, and the port of the site you want to proxy. Save the settings.
Enabling and Setting Up SSL through Cloudflare:
- Login to your Cloudflare Account, Make sure that your Domain is pointing to Cloudflare as DNS.
- On the top right, select "My Profile" -> API Tokens -> Create Token
- Select the template "Edit zone DNS" click Use Template
- Change the Token Name, and Under Zone resources -> Change to All Zones -> Continue to Summary
- Create Token. A long string of token will show and Copy it, if possible save it to a secure location for later usage.
- Log in back to your NGINX Proxy Manager URL
- Click SSL Certificates and Click Add SSL Certificate and Select Let's Encrypt
- Fill up the form. Doamin Name - I use wild card to allow subdomains to be used
- Select DNS Challenge and Choose Cloudflare
- Replace the Token from the generated token in Cloudflare
- Hit I agree and Save
- Now add PROXY HOST with the correct IP and Port and choose the generated SSL you just created.
- And Thats it, your site is using the Lets Encrypt SSL Cert.
0 Comments
No Comments Yet!
© TopITSolutions. All Rights Reserved.