Nginx Script check if App Service endpoint URL and restrict viewing of resource (htm/html) only to logged in users

Stephen Wartel 60 Reputation points
2023-06-18T19:46:31.8633333+00:00

Beginner using Nginx SSH terminal in App Service (WordPress). Been reading/experimenting with a range of scripting attempts to achieve the result described below, so far unsuccessfully.

Noticed that clicking on link in WordPress page to view HTM/HTML file (entry point for small web-based app), redirects to "backbone" endpoint. If I would like to restrict viewing of this HTM/HTML file, wondered how I could create Nginx script in SSH terminal to add in the server block to a new default.conf (copied over to /home so it persists, started by custom startup command, for when server restarts). I can set up everything but a working script thanks to this helpful posting.

Problem is creating the Nginx script addition to accomplish: (1) checking if the requested path is the endpoint server and file, (2) if matched, and then a check of WP user-sign-in cookie or WP Simple Membership cookie (swpm_in_use) is not present, redirecting to sign-in or sign-up page, (3) if user-sign in or WP Simple Membership cookie is present, allowing the access/viewing of the backbone endpoint's web-based app's entry HTM/HTML file (for example, index.html).

Any help, examples, much appreciated.

Thank you in advance for your help.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2023-07-03T08:19:40.25+00:00

    @Stephen Wartel Thanks for confirmation. Sharing the resolution which works for you. I am resharing here for helping wider community facing similar issues.

    Update- The issue is resolved -

    Added new rule in CDN endpoint to modify response header Content Security Policy to frame-ancestors <my referrer URL-which is the custom domain>, which now allows an iFrame (sourced from the CDN backend) to be embedded in the calling WordPress page with no block.

    Calling page in WordPress can be restricted to user/membership level to  assure that helping exercise safe-use lesson is completed first (safety goal of access restriction).

    Please accept as "Yes" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.