Jump to content

Akash Bhati

Members
  • Posts

    1
  • Joined

  • Last visited

Akash Bhati's Achievements

Newbie

Newbie (1/14)

  • One Month Later
  • Week One Done
  • First Post

Recent Badges

1

Reputation

  1. Hello, Firstly, the conditions and rules you mentioned are in Apache's mod_rewrite syntax, but Nginx uses a different configuration style. Here is the corresponding setup in Nginx: Let me explain what this does: location /admin: This block applies to any URL path that starts with /admin. allow 88.85.69.0/24; deny all;: These two lines control access to the /admin directory. Only IP addresses in the range 88.85.69.0 to 88.85.69.255 are allowed. All other IP addresses are denied. error_page 403 =404 /404.html;: This changes the error page for forbidden requests (403 errors) to your 404 error page. Replace /404.html with the path to your actual 404 error page. try_files $uri $uri/ =404;: This tries to serve the request as is, or as a directory, and if neither of those exist, it returns a 404 error. location ~ \.php$ { deny all; }: This nested location block matches any PHP file in the /admin directory and denies access to it. However, please be careful as this block will need to be adjusted to fit in with your existing PHP execution configuration, especially if you're using PHP-FPM or similar. In Nginx, the client's IP is taken from the connection itself and not from an HTTP header like HTTP:X-REAL-IP as in your Apache configuration. If you're behind a proxy and want to allow/deny based on the original client IP, you'll need to use the ngx_http_realip_module and define trusted sources to get the real IP.
×
×
  • Create New...