DNS Record Type | Sub-domain | IP address |
---|---|---|
A | pang | 142.142.254.12 |
A | \* | 142.142.254.12 |
It's important to click the 'Create Site' button before starting the Newt application, or it will give an error that it can't find the endpoint or connect. If you see that error, simply return to your Pangolin dashboard, and finish creating your site by clicking the button. Newt will try again in 10 seconds, and should connect.
Now, we need to create a system service so Newt will run automatically, in the background, and even when we reboot the node. In the node's terminal, we'll create a file called 'newt.service'. `nano newt.service` Now, copy the code block below, and paste it into the file you just created. ```plaintext [Unit] Description=Newt VPN Client After=network.target [Service] ExecStart= Restart=always User=root [Install] WantedBy=multi-user.target ``` Now, we need to add the startup command for newt with your node's id, secret key, and endpoint. This was the second part of the command we copied from your Pangolin dashboard. Save the 'newt.service' file with CTRL + O, press Enter to confirm, and exit the editor with CTRL + X. Now use the up arrow key on your keyboard to view the previously entered commands. When you see the long command you pasted earlier, copy the last half of the command starting with `./newt` . It should look something like: `/newt --id s0m3l0n6rAnD0MS7r1n6 --secret aN3venL0n6erRAnD0mStr1n6ofchARAC73r5 --endpoint https://proxy.yourgreatdomain.com` Re-open the 'newt.service' file with `nano newt.service` and paste this line in after the equal '=' sign on the line with "ExecStart=". Modify the beginning of the command by removing the `./` and adding `/usr/local/bin/` to it. So the whole line should look like: `ExecStart=/usr/local/bin/newt --id s0m3l0n6rAnD0MS7r1n6 --secret aN3venL0n6erRAnD0mStr1n6ofchARAC73r5 --endpoint https://proxy.yourgreatdomain.com` Save the file again with CTRL + O, then press Enter to confirm, and exit the file with CTRL + X. Now we need to move our "newt" application to the `/usr/local/bin` location with: `sudo mv newt /usr/local/bin/` Next, we need to move the service file we just created to `/etc/systemd/system` with `sudo mv newt.service /etc/systemd/system/` Finally, we'll start and enable our newt service with the commands: `sudo systemctl start newt.service` and `sudo systemctl enable newt.service` We can check the newt.service status to ensure it's active and running with: `sudo systemctl status newt.service` You should see that it's **active** and that it is running ping checks in the logging section. This indicates that the newt service is running, and that you now have a tunnel from your ingress node out to your Pangolin server. You are not restricted to a single site (node) with Pangolin. you can have multiple nodes, and can have multiple organizations to help you create tunnels for all your services regardless of where they are hosted. --- ## Service (Resource) Setup on your LAN Now we want to create access to our services (called Resources in Pangolin). 1. Click on 'Resources' in the left navigation. 2. Click the 'Add Resource +' button near the upper right of the view. 3. Give your Resource (site) a recognizable name. For instance if you are setting access to Jellyfin, then name it Jellyfin. 4. Next, you can choose from any nodes you've setup for the organization in the 'Site' drop down. You need to choose a node which will have local (LAN) access to the service, or localhost access if both the Newt node and service are running on the same machine. 5. For resource type, you can choose 'HTTP Resource'. 6. In the HTTP Settings section, give your resource a sub-domain. For instance, with Jellyfin, you may just want to use 'jellyfin', or maybe just 'jf'. It's up to you. 7. Make sure the proper base domain (e.g. yourgreatdomain.com) is selected in the drop down. 8. Click 'Create Resource'. 9. On the next screen, choose the 'Method' (http or https usually). 10. Then enter the local IPv4 address of the resource (e.g. 192.168.1.24) 11. Finally, enter the port the service runs on (e.g. 8096 for Jellyfin, or 8123 for Home Assistant, etc). 12. Click the 'Add Target' button. 13. Then click the 'Save Target' button. 14. You should now be able to access your application (resource) over the internet by using the FQDN (fully qualified domain name) you've setup for it. --- ### Multiple Domains in Pangolin If you're like me, then you may own a few domains, and want to use Pangolin to act as a tunnel for all of them. This is 100% possible with Pangolin, but we need to make a quick edit to our Pangolin server. Let's say you want to use Pangolin to proxy traffic for your domains yourgreatdomain.com, domainsrock.com and opensourcerocks.org. You need to do a few things to make this successful. #### Create DNS A Wildcard (\*) Records You need to create a wildcard (\*) A-Record for each domain, and make sure it points to your Pangolin Server's public IPv4 address. If your server's public address is 212.145.66.21 then you'd want three A records. ```plaintext Type Subdomain Base Domain IPv4 A * .yourgreatdomain.com 212.145.66.21 A * .domainsrock.com 212.145.66.21 A * .opensourcerocks.org 212.145.66.21 ``` You still need the single DNS A Record which points your subdomain to the dashboard access for Pangolin: `proxy.yourgreatdomain.com -> 212.145.66.21` This is still the FQDN you use to access the Pangolin admin dashboard. #### Update the Pangolin Server Config SSH or access your Pangolin server, and find the files that the Pangolin install script created. You should see something like this: ```plaintext $~ ls config docker-compose.yml installer $~ ``` We need to go into the "config" folder, `cd config` Now we need to open the "config.yml" file and make some additions. `sudo nano config.yml` You'll see something that looks like the below: ```plaintext # To see all available options, please visit the docs: # https://docs.fossorial.io/Pangolin/Configuration/config app: dashboard_url: "https://proxy.yourgreatdomain.com" log_level: "info" save_logs: false domains: domain1: base_domain: "yourgreatdomain.com" cert_resolver: "letsencrypt" server: external_port: 3000 internal_port: 3001 next_port: 3002 internal_hostname: "proxy" session_cookie_name: "p_session_token" resource_access_token_param: "p_token" resource_access_token_headers: id: "P-Access-Token-Id" token: "P-Access-Token" resource_session_request_param: "p_session_request" secret: somesuperlongcharacterstringoflength cors: origins: ["https://proxy.yourgreatdomain.com"] methods: ["GET", "POST", "PUT", "DELETE", "PATCH"] allowed_headers: ["X-CSRF-Token", "Content-Type"] credentials: false traefik: cert_resolver: "letsencrypt" http_entrypoint: "web" https_entrypoint: "websecure" gerbil: start_port: 51820 base_endpoint: "proxy.yourgreatdomain.com" use_subdomain: false block_size: 24 site_block_size: 30 subnet_group: 100.89.240.0/20 rate_limits: global: window_minutes: 1 max_requests: 500 users: server_admin: email: "admin@yourgreatdomain.com" password: "a-server-admin-password" flags: require_email_verification: false disable_signup_without_invite: true disable_user_create_org: false allow_raw_resources: true allow_base_domain_resources: true ``` In this file, we want to add more domains subsections. Under the main 'domains' section, we'll create a new line, then add the appropriate spaces.Remember, YAML is space dependent. We want to use the proper number of spaces so each subsection lines up with the same indentation level as the subsection above it.
Looking at the modified 'config.yml' file below, you'll notice I've added two more domain subsections to the yaml file. They look like this within the 'domains:' section. ```plaintext domain2: base_domain: "domainsrock.com" cert_resolver: "letsencrypt" domain3: base_domain: "opensourcerocks.org" cert_resolver: "letsencrypt" ``` First, you add a new domain count subsection (e.g. 'domain2', 'domain3', and so on). Next, under each subsection we add the item for the 'base\_domain', and the associated 'cert\_resolver'. In most cases, you'll want the 'cert\_resolver' to be 'letsencrypt'. Add the appropriate subsections for your additional domains into the 'config.yml' file. ```plaintext # To see all available options, please visit the docs: # https://docs.fossorial.io/Pangolin/Configuration/config app: dashboard_url: "https://proxy.yourgreatdomain.com" log_level: "info" save_logs: false domains: domain1: base_domain: "yourgreatdomain.com" cert_resolver: "letsencrypt" domain2: base_domain: "domainsrock.com" cert_resolver: "letsencrypt" domain3: base_domain: "opensourcerocks.org" cert_resolver: "letsencrypt" server: external_port: 3000 internal_port: 3001 next_port: 3002 internal_hostname: "proxy" session_cookie_name: "p_session_token" resource_access_token_param: "p_token" resource_access_token_headers: id: "P-Access-Token-Id" token: "P-Access-Token" resource_session_request_param: "p_session_request" secret: somesuperlongcharacterstringoflength cors: origins: ["https://proxy.yourgreatdomain.com"] methods: ["GET", "POST", "PUT", "DELETE", "PATCH"] allowed_headers: ["X-CSRF-Token", "Content-Type"] credentials: false traefik: cert_resolver: "letsencrypt" http_entrypoint: "web" https_entrypoint: "websecure" gerbil: start_port: 51820 base_endpoint: "proxy.yourgreatdomain.com" use_subdomain: false block_size: 24 site_block_size: 30 subnet_group: 100.89.240.0/20 rate_limits: global: window_minutes: 1 max_requests: 500 users: server_admin: email: "admin@yourgreatdomain.com" password: "a-server-admin-password" flags: require_email_verification: false disable_signup_without_invite: true disable_user_create_org: false allow_raw_resources: true allow_base_domain_resources: true ``` Once added, save the file with CTRL + O, then press Enter to confirm, and exit the nano editor with CTRL + X. Now we need to restart the Pangolin server with the commands: `docker compose down` Once that completes, enter `docker compose up -d` Wait for the start up to complete, return to your Pangolin dashboard in the browser, and refresh it. Now when you go to add a resource, the base\_domain drop-down field should list all of your added domains as options.