DEV Community

Arnob
Arnob

Posted on

Configure Kubernetes & Manage Other Domains by using Nginx Proxy Manager

Here I used CNAME instead of an IP because I needed to run both Proxy Manager and Kubernetes, but both use port 80. One had to run on port 80 directly, and the other through CNAME. Since I hadn’t used CNAME before, I had to learn and test it and finally, I got it working.

nginx proxy manager

What is Nginx Proxy Manager?

Expose your web services easily with free SSL from Let’s Encrypt.
Built with security in mind, it’s perfect for home or private networks.
You can manage Proxy Hosts, Redirection Hosts, Streams.

Deploying Nginx Proxy Manager To VM

1st you have to install docker. For using the NPM.
Create an docker-compose.yml

services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
    environment:
      # Mysql/Maria connection parameters:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"

    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db
  db:
    image: 'jc21/mariadb-aria:latest'
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
      MARIADB_AUTO_UPGRADE: '1'
    volumes:
      - ./mysql:/var/lib/mysql
Enter fullscreen mode Exit fullscreen mode

Run the docker compose

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

https://nginxproxymanager.com/screenshots/login.png

The Default Administrator User

Email:    admin@example.com
Password: changeme
Enter fullscreen mode Exit fullscreen mode

Change the password and email after login

Also you can modify in docker-compose.yml

environment:
      INITIAL_ADMIN_EMAIL: my@example.com
      INITIAL_ADMIN_PASSWORD: mypassword1
Enter fullscreen mode Exit fullscreen mode


Image from nginxproxymanager screenshort

After Login

image from nginx proxy manager screenshort

Now Creating an Proxy Host

image from nginx proxy manager screenshort

Note: The dashboard will empty, Here i sharing my dashboard.

Networking:

Now its time to configure the Network. We will make the 80 port with Proxy manager also kubernetes. So my router is mikrotik

First Step: We are going to configure Proxy Manager

Check and get proxy manager ip

captionless image

Here is the ip is 192.168.88.180

Now target the ip to mikrotik. At Mikrotik goto IP > Firewall > NAT

Add an NAT rules

captionless image

Note: Please add your public ip at Dst. Address (change from X.X.X.X to public ip).

Then add the local ip at Action.

captionless image

After that need to create and Proxy Host at Proxy Manager, Goto Dashboard, Click Add Proxy Host button.

captionless image

Note: I configure that previously so here is the edit tab.

Here is the details:
Sub-Domain: proxy.arn-ob.xyz
Scheme: http
Forward IP: 192.168.88.180
Forward Port: 80

No need to configure the SSL.

Now goto Cloudflare, Add that sub domain to DNS

captionless image

This now using CNAME, for other sub domain at Cloudflare

Another config are need, that is Cloudflare SSL/TLS. Make sure the Current encryption mode is Full

Cloudflare SSL/TLS Ency Type

Networking Part is Done.

Proxy Manager Configure

Now adding kubernetes nginx ingress ip to nginx proxy manager.

Now getting ip from vm. Goto VM open terminal type

ip a
Enter fullscreen mode Exit fullscreen mode

At output you will find the ip. Copy that.

captionless image

Now check the ingress is it giving private ip or not

captionless image

VM ip and kubernetes ingress not same, its ok. In the behind i using MetalLB. It will manage the internal networking.

Then Goto Dashboard, Click Add Proxy Host button

captionless image

Give the Domain Name, Scheme, Forward Hostname/IP, Forward Port

Here the details:

  • Domain Name: nginx.arn-ob.xyz
  • Scheme: http
  • Forward Hostname/IP: 192.168.88.175 (kubernetes ingress ip)
  • Forward Port: 80

Now add the SSL from Let’s Encrypt, Go to SSL Tab, Then you see this

captionless image

Here the config

captionless image

Request a SSL Certificate. Also enable HTTP/2 Support. Then give the check mark of I Agree. Then Save.

If give an Internal Error. Then Check you enable 80 port or your router NAT config which based on proxy manager private IP with public IP

Then Add the record to Cloudflare DNS

captionless image

Remember we add the proxy.arn-ob.xyz sub-domain with External IP.

Now for nginx.arn-ob.xyz sub-domain mapping Content with the proxy.arn-ob.xyz as type as CNAME.

Now hit the browser with the domain nginx.arn-ob.xyz. Hope you will see this screen

captionless image

Thank you for Reading.

Top comments (0)