OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • [SOLVED]: HAProxy with authentication
« previous next »
  • Print
Pages: [1]

Author Topic: [SOLVED]: HAProxy with authentication  (Read 9067 times)

morcom

  • Newbie
  • *
  • Posts: 6
  • Karma: 2
    • View Profile
[SOLVED]: HAProxy with authentication
« on: July 19, 2016, 05:39:56 pm »
Hi,

I have HA Proxy finally working - modifying some firewall rules - but as expected.

Now I have second question...
Server should be accessible after authentication - just basic.
I know in HAProxy I can do that  in theory adding some extra configuration like

Code: [Select]
userlist httpusers
  user username insecure-password password

frontend server2
  acl auth_acl http_auth(httpusers)
  http-request auth realm basicauth unless auth_acl

Can I do that through HAProxy GUI - or the only possibility is to dig inside the config file from CLI?

If GUI is possible to use - any suggestions?

Thanks in advance for help

Mike
« Last Edit: July 20, 2016, 11:31:46 am by morcom »
Logged

morcom

  • Newbie
  • *
  • Posts: 6
  • Karma: 2
    • View Profile
Re: HAProxy with authentication
« Reply #1 on: July 20, 2016, 11:31:26 am »
 :)

Looks like solved.

So actually Advanced configuration is needed.

In General -> Global Parameters in Advanced mode:

Custom options:
Code: [Select]
userlist httpusers
  user username insecure-password password

Then in Frontend -> Advanced configuration

Options pass-through:
Code: [Select]
  acl auth_acl http_auth(httpusers)
  http-request auth realm basicauth unless auth_acl

Then you test syntax and then you Apply.

I would suggest to restart as well HAProxy.

I have noticed after changes that after restart HAProxy is not always up. In that case if I Disable and Enable HAProxy - it is up back. Starting from dashboard was not working for me... but maybe it is just me.

After that be sure to clean all your cookies and access the site. It should ask for authentication.

That is what was needed.... So it works fine.

Self solving - I need just to be more familiar with the way how the OPNsense is working. But so far - I like this. I like flexibility - and so far in most cases it is very flexibel.

Thanks

Mike
« Last Edit: July 20, 2016, 12:14:31 pm by morcom »
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17707
  • Karma: 1618
    • View Profile
Re: [SOLVED]: HAProxy with authentication
« Reply #2 on: July 21, 2016, 09:45:36 am »
Hi Mike,

Thanks for the step by step guide. This will be helpful for others down the road. :)

"Fraenki" is the maintainer of the HAProxy plugin, talking to him directly may be of value to you too.


Cheers,
Franco
Logged

dragon2611

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 4
    • View Profile
Re: [SOLVED]: HAProxy with authentication
« Reply #3 on: January 13, 2018, 01:58:34 pm »
Just a couple notes:

1) It's now in Settings > Global Paramaters

2) The config to use HTTP auth can either go in Virtual Services  > Public Services (New name for Frontend) OR Virtual Services > Backend Pools

what you do in 2 largely depends if you want to force authentication for everything served by that frontend instance or if you have multiple backend servers/sites you may only want to force authentication on some of them.
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • [SOLVED]: HAProxy with authentication
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2