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

128
Views
Make server app accept requests only from the client app in the same hosting

I have an angular and php apps hosted in the same shared hosting and are accessible from the same domain example.com. The php app expose a rest api, and I want this api to be accessible only from the angular app.

Both apps don't have user authentication.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The best way to do it is to place your backend in private subnet which is accessible to the frontend angular via internal network route.

                       [ Your network /16 ]
            [ Public Subnet /24 ] [ Private Subnet /24 ]
               [Frontend]  <-  Route ->   [Backend]

But base on your case you are hosting both in the same server instance which are public. Which the above recommendation is not applicate. Since you cannot restrict it in the network layer you can look into application layer and you can utilize web server config extension such as .htaccess, you can create a rule that only allows frontend request. It's an application layer restriction.

over 4 years ago · Santiago Trujillo Report

0

As @Edcel Cabrera Vista mentioned, I tried to restrict the calls in the application layer by adding rules to .htaccess file, Checking in the PHP file if the incoming client IP matches my website ip or localhost, adding basic authorization. None of them work, because the angular app in the end is just a client JS code that runs in the user's browser, so the user has total control about it and the client IP will always be the user's IP.

I realized in the end that I could do the HTML rendering in the server side, and return the ready HTML page to the client. For the moment that suits my needs.

over 4 years ago · Santiago Trujillo Report
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!