79

Pfsense, windows and wsl (docker) on VMware

Configure your pfsense to serve a docker website hosted on your windows pc

Configuring Vmware for Pfsense

  1. Download and install VMware
  2. Configure vmware networks
  1. Open VMware and create a new container for pfsense with following specifications :
  • Minimum 1cpu processor (adding extra processor might fail the vm to start)
  • Minimum 1gb ram ( the more, the faster the installation)
  • Add the two network devices we created earlier ( Bridge and Host-Only)
  • Minimum 16gb storage suggested ( can be lower)
  1. Install Pfsense on vmware wiki
  • (Once the pfense has done installing and restarted you might get in the installation loop process, to evict this error try to remove the iso attached to the container and restart. This will fix the problem.)

Pfsense

web setup

  1. You will be provided with two ips normally on your pfsense shell. Image
  2. Use the lan ip and put it in your web browser. webpage
  • User is admin and password is pfsense
  1. Run the web setup : Just keep the defaults as we dont need them image

image

image Be sure to disable these two as they will block wan access otherwise which we need for our configuration to work properly.

image I am using 192.168.0.1 / 24 as i declared these values in my vmware network config wiki. If you are following my guide keep it this way so you don't get any issues.

Setting dns forwarder

We need to enable dns forwarder so requests to domains are passed through pfsense and not our router provider. In simple terms, when we declare a nat entry with domain name in pfsense it will not work as our router dns doesnt recognize those domains.

  1. Disable DNS Resolver Services -> DNS Resolver and untick it and save the settings,
  2. Enable DNS Forwarder Services -> DNS Forwarder and enable it.

Docker

  1. You will need to create a simple web app in docker where our site will be hosted.
version: '2'
services:
    app:
        image: strm/helloworld-http
        ports:
            - "8000:80"
  1. After creating the file, you will need to do docker compose up ( make sure your docker is running or you will get an error).
  2. Once started you will get a message like this image.
  3. Now go to your web browser type localhost:8000 and you will see a hello from your container.
Docker config is done and all we need to do is make a NAT rule in our pfsense firewall for it to forward wan address to the website.

Back to pfsense web panel

  1. Click Firewall and then NAT image
  2. Click on Add image
  3. Just change the following and make sure interface is WAN
  • Protocol = TCP
  • Destination = WAN address
  • Destination port range = HTTP
  • Redirect target IP = Address or Alias = IP of your Windows PC ( Duplicate the page to keep the entries, on the other page click Diagnostics and ARP table and find the LAN IP of your pc. In my case its 192.168.0.2. Copy the ip and go back to other page.) image
  • Redirect target port = 8000

AND click save. image Apply the changes and go to FIrewall -> Rules to see if the WAN rule is created successfully. image

Results

If everything done as explained you will most likely be able to see the "Hello from vhzzhj ( random letters of your container)" on your WAN IP.