Blocking access to the admin panel via .htaccess - .htaccess

How can I block all IP addresses for accessing the admin panel of my site and make my PC the only device that can access the site. I used this code:
order deny,allow
deny from all
allow from ***public_IP***
but it would allow all the IP addresses within the network. I was figuring out how to block ALL including addresses within the network. One problem I encounter is that the addresses are dynamic. As I search google, people are saying that the code above is cannot be used to dynamic IP's.
What can you suggest?

Connect via a VPN and Whitelist the VPN IP only instead.
If you want privacy, you will have to set up a network which only have you in it.

Related

Issue with IP Addresses and Domain Restrictions in IIS

i have windows server 2019 with iis 10 installed, ip and domain restriction enabled ip range 10.0.0.1=>10.0.0.240 - domain name : lo-server.com
the problem that am facing is : when adding a local ip address / Same ip with server / same network / example 10.0.0.66 to deny list it works perfectly it deny the access
but when i add an ip address outside the network / 192.168.20.10 / which is connected to a firewall ( FortiGate ) 10.0.0.200 the restriction doesn't work i need to add the firewall ip to deny it which i don't want to do it because i'll block all the ranges that are connected to the firewall.
how can i deny access to another network without adding the firewall
Microsoft considered the simplest case for you and implemented the so called Proxy mode, which you might try out,
https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions#configuring-iis-for-proxy-mode
Deep down inside it checks x-forwarded-for header to see whether the incoming HTTP requests are through a proxy (the firewall in your case) and then apply the rules to decide whether to deny any request.
However, a real world proxy can manipulate the incoming requests in too many ways, so the proxy mode might fail you and you will have to switch to something like URL Rewrite module and write a more complicated rule to abort the desired requests.
You can use the IP Address and Domain Restrictions feature page to define and manage rules that allow or deny access to content for a specific IP address, a range of IP addresses, or a domain name or names.
Opens the Add Deny Restriction Rule dialog box from which you can define rules that allow access to content for a specific IP address, a range of IP addresses, or a DNS domain name.
More information you can refer to this link: IP Address and Domain Restrictions.

Accessing IIS website from another device without creating an inbound rule

I have deployed my flask application on IIS using the IP address. I want to access this from another PC in the network, I have read about creating an inbound rule and allowing the access but is there a safer way to do this?
In my opinion, you could use the 80 port which is usually an open port.
if you want to use another port you can set the firewall and use the private only in profile:
after that, you could use iis IP and domain name restriction to restrict the other ip then the remote machine IP.
you can follow the below steps to allow connections from specific IP addresses:
1)Open IIS Manager
2)In IIS Manager, expand SERVERNAME > Sites > click on a required website > double-click IP Address and Domain Restrictions
3)Click Add Allow Entry... (on the right pane) to add an IP address or IP address range that will be allowed to access the website. Click OK.
4)Once allowed IP addresses have been added, click Edit Feature Settings... and select Deny for Access for unspecified clients. Click OK.
Now, only users with the specified IP addresses are able to access the website.

Is secure to let access to ip-based blocked website to 127.0.0.1?

I have a website that should not be visible for people outside some countries.
I do a ip-blocking, but for testing purposes I need to let 127.0.0.1 access to the website. I know that ip blocking isn't totally safe, but, letting 127.0.0.1 access, can create troubles?
127.0.0.1 is simply your localhost. Allowing this IP simply says that you allow this machine (and only this if 127.0.0.1 is the only IP you whitelisted) to access the Network so no, there wouldn't be any issue with allowing access to your localhost so long as that machine itself isn't compromised. Note: loopback address is not publicly-facing but are re-routed by the machine's network adapter.
Resources:
Wikipedia
howtogeek

How to keep admin area of the website accessible by only specific devices?

Scenario :
The website is hosted on shared hosting and currently only protected with username and pass, which may be leaked by employees.
admin panel is located at xyz.com/admin and I want it to be accessible by only specific devices on our network and deny all other public / external access.
Since the IP address of the network is Dynamic using .htaccess is not possible.
Considering that the devices you want to give access to the website will be on same network Try the following code:
order deny,allow
deny from all
allow from 173.194.36.3
replace the IP address with your network's external IP address check that by googling what's my IP.
save that code to .htaccess file on the root of your web application.
UPDATE : Having the issue of Dynamic IP install a DNS updater on the client devices and replace the ip with the host name provided by DNS updater.
noip client for windows what it does is updates you dynamic ip to its host name created for you , that it will solve that issue

Sonicwall Access Rule - Limit Access to Specific IP

I have a SonicWall TZ200 and used the Wizard to create a port forwarding for PPTP which is working great. Now, I want to limit the EXTERNAL IP addresses that can use this port forwarding rule so that it only allows connections from a couple employees static home IP addresses.
I created an Address Object for the external home IP address. Then I went to Access Rules WAN>LAN. For the PPTP rule I changed Allow Source to the Address Object for the home IP address.
But, I can still access the VPN from a different external IP address so it's obviously not blocking anything else.
What am I missing?
You need to set your NAT policy. The "Home" IP addresses are added at the "Original Destination" part of your policy.

Resources