How to use the pfsense name instead of the IP address in http?
-
http://192.168.1.1:8002/index.php?zone=pass&redirurl=http%3A%2F%2Fqq.com%2F
I want to change it to look like this.
http://pfsense:8002/index.php?zone=pass&redirurl=http%3A%2F%2Fqq.com%2F
May I ask which part you would like to modify?
Please help me, thank you very much. -
@goldsoft said in How to use the pfsense name instead of the IP address in http?:
I want to change it to look like this.
http://pfsense:8002/index.php?zone=pass&redirurl=http%3A%2F%2Fqq.com%2FYou can't use "pfsense" as a host name, as you shouldn't 'break' the (DNS) rules.
What would work, as DNS knows about it : you already gave it a name :
So, http://pfsense.domain.tld/..... will work.
Normally, a portal user would never have to know about that "pfsense.domain.tld" hostname, or even "192.168.1.1".
When connecting to a network by cable or more common : Wifi, the user will get an login page without any interaction from his side.Btw : the portal, using http mode, redirect to the IP, the "192.168.1.1" you've seen.
To use host names, you have to use the https mode - see below.If possible, don't use the portal on your "192.168.1.1/24" LAN, as LAN is reserved for your trusted devices.
Typically, your non trusted devices should use the portal on another interface, like 192.168.2.14/24.If your willing to loose some less then 10$ per year, get (rent, actually) a domain name.
Now you can get a certificate for this domain name, and use a host name like portal.your-domain.tld, using https.
This looks better, as https uses host names, not an IP address like "192.168.2.1".The portal visitor will see https://portal.your-domain.tld/ and it will trust the certificate used.
Goto Services > DNS Resolver > General Settings - and scroll down.
At Host Overrides, add : -
@Gertjan I want to give multiple clients, each with a PfSense firewall. However, filling in my domain name and configuring certificates on each router will only increase the complexity of maintenance and increase the failure rate. http://pfsense:8002***** The reason for adopting this approach is to prevent unauthorized connection of downstream routers to the network. I have tested it and found that pinging PfSense fails on the downstream routers, which effectively blocks them.
-
@goldsoft said in How to use the pfsense name instead of the IP address in http?:
filling in my domain name and configuring certificates on each router will only increase the complexity of maintenance and increase the failure rate.
I use a domain name, and the only "admin" part is : I have to pay for it every year.
The rest : certificates renewal etc etc is is handled automatically (see the pfSense acme.sh package).
It works well for years now.
My pfSense captive portal doesn't need my time.For reasons, I prefer not to use (show to the client) things like "http", with an IPv4 address.
Btw : soon to be IPv6 : you'll scare the client now ;)Use a host name.
Look at the /var/etc/nginx-YOURZONENAME-CaptivePortal.conf file.
You'll see :.... if ($http_host ~* 192.168.2.1) { set $cp_redirect no; ...
so the IPv4 (yours is 192.168.1.1) is hard coded.
Maybe you can change this into a host name ( I guess its possible) ???@goldsoft said in How to use the pfsense name instead of the IP address in http?:
The reason for adopting this approach is to prevent unauthorized connection of downstream routers to the network. I have tested it and found that pinging PfSense fails on the downstream routers, which effectively blocks them
Blocking routers ? I guess I understand your reasons, the question has been asked before.
The answer will be : you can't block easily "router" devices.
How would you (pfSense) know that IPv4 (example) 192.168.1.51 using MAC aa:bb:cc:dd:ee:ff is a router and not an iPhone ? (MAC will be spoofed !) -
After restarting the service, the hostname will automatically change to IP 192.168.0.1, and the file nginx-pass-CaptivePortal.conf has been automatically rewritten.
-
Because :
@Gertjan said in How to use the pfsense name instead of the IP address in http?:
is hard coded
so editing the nginx config is useless, as pfSense re creates that config file every time it starts nginx.
When you look at your own file at /etc/inc/system.inc, you'll find it around line 1331 (the github version is ahead - more recent).
Instead of
$cp_hostcheck .= "\t\tif (\$http_host ~* $cpint_ip) {\n";
you change that to
$cp_hostcheck .= "\t\tif (\$http_host ~* pf.home.arpa) {\n";
-
-
@Gertjan
After modifying the /etc/inc/system.inc file, the nginx-pass-CaptivePortal.conf file can correctly display the domain pf.home.arpa, and it still displays after restarting the service, indicating that the modification is successful. However, the login page has not changed and still appears in the form of an IP address, http://192.168.0.1:8002/index.php?zone=pass&redirurl=http%3A%2F%2Fqq.com%2F. -
I just tested the http login .... and yes, I saw also "192.168.2.1".
So more work needs to be done.
The story continues here /etc/inc/captiveportal.inc locate function portal_reply_page() around line 1811.Four lines lower, you'll see
$ourhostname = portal_hostname_from_client_ip($clientip);That function return the IP if http was chosen, the domain name if otherwise (https).
A solution might be : locate function portal_hostname_from_client_ip($cliip) :
After $ifip = portal_ip_from_client_ip($cliip);
Add on a new line :
$ifip = false;Like this :
but take note : this is messy.
Its always easier to do what the entire planet does : use https, as it is the future -
And keep in mind that after each update you need to make this changes again.
So I do with my changes for printing QR codes for voucher access.Regards
-
@Gertjan
The IP address has been successfully transformed into a domain name, but it also caused a deadlock. How can this be resolvedhttp://pfsense.home.arpa:8002/index.php?zone=pass&redirurl=http%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fqq.com
-
-
@goldsoft said in How to use the pfsense name instead of the IP address in http?:
How can this be resolved
By undoing what you did, so you'll get the stable situation back.
Its (not) clear to me that more has to be changed.
Sorry, can't do more here. -
This post is deleted! -
@Gertjan Thank you very much for your guidance.
-
@goldsoft said in How to use the pfsense name instead of the IP address in http?:
@Gertjan
The IP address has been successfully transformed into a domain name, but it also caused a deadlock. How can this be resolvedhttp://pfsense.home.arpa:8002/index.php?zone=pass&redirurl=http%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fpfsense.home.arpa%3A8002%2Fhttp%3A%2F%2Fqq.com
I hope someone can help me solve this problem because I really need this functionality.
-
-
Try this :
Force redirect to preset URL :I know, not a real solution, but it would break the recursive redirection.
-
@Gertjan The user has been authenticated and can access the internet. Further redirection would be meaningless
-
I get it.
Consider this : when you visit the captive portal's IP or host name manually, the request will get handled by the nginx (the web server handling the captive pirtal login page) : the used host name will be stored in the redirect parameter.
Or, the url (host name) is the host name of the web server itself.
After a valid login, you will get redirected to this 'redirected url'.
Which was ... the same page.
And from now on, this goes in circles : you saw what happens.Simple solution : never enter or use the captive portal's host name, as the portal will auto redirect to this url anyway.
To break this redirect loop, I proposed the 'https://www.whatver.tld' solution.
-
@goldsoft To change the URL, you can follow these steps:
Access your router settings. Look for the configuration related to the URL or redirection. Replace "http://192.168.1.1" with "http://pfsense" in the configuration. Save the changes.
This should update the URL as you want. If you need more detailed instructions, please specify your router model for further assistance. Also, consider using the essay writing service at for academic help.