Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Adding Apache basic auth to a headless backend and single page app frontend

I'm working on a project that I want to hide from the world behind Apache's basic auth whilst it's in development. The project has a PHP backend and a JS frontend on different virtual hosts. I have successfully setup basic auth on the backend and the JS application can make requests to it with the following configuration (123.456.789 being the JS application's IP address):

<Directory "/some/backend/folder">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All

        Order allow,deny
        allow from all

        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /some/path/.htpasswd

        <RequireAny>
                Require valid-user
                Require ip 123.456.789
        </RequireAny>
</Directory>

The JS application's virtual host proxies requests to a Node server which ultimately handles any requests to the backend, using the following configuration:

ProxyPreserveHost On
ProxyRequests On
ProxyVia On

ProxyPass / http://0.0.0.0:3000/ connectiontimeout=600 timeout=600

I also want to add basic auth to this so that the world cannot access the frontend application. I've tried adding the following:

<Proxy *>
       Order deny,allow
       Allow from all
       AuthType Basic
       AuthName "Restricted Content"
       AuthUserFile /some/path/.htpasswd
       Require valid-user
</Proxy>

Which seemed to work at first, however all the previously working requests to the backend server now 401 which is rather confusing.

Does anybody know what's going on here? Does the act of adding basic auth to the proxy frontend virtual host screw-up the RequireAny config on the backend virtual host?

Any pointers greatly appreciated! Thanks

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!