Disable IP access in browser but domain name still accessible - browser

My site is currently accessible to the server's ip via browser. I want to disable this and everyone should go through using domain name like www.mydomainsite.com.
For example, if I type 58.123.45.18 (not a real ip) in the browser it still goes to the site.
We have a proxy server sitting between the dns and web server and we want to track anyone who comes in. But w00tw00t.at.blackhats.romanian.anti-sec still get in using the IP.
My google search return this: http://support.microsoft.com/kb/324066
and I dont want to do this.
Is this even possible in the first place??

It's not possible to prevent a browser from connecting to your site using an IP address. After all, for this purpose, the DNS system is simply a friendly name layer on top of IP addresses.
The only thing you can really do is filter the URLs that are presented to your web server. While you can certainly do this at the application layer, you're far better off using the capabilities already built into your web server for doing this.
I assume you're using IIS based on the link you posted. Any good reason for not using the built-in capability to accomplish what you want?

You can't disable accessing the server with your ip but you can redirect direct access with the IP address to your domain which will then be resolved and redirect the browser back to your server. You can achieve this by placing a .htaccess file in your BROWSING home directory. Note: this is not your home directory. Your browsing home directory is usually /var/www/ or /home/admin/web/{domain.ltd}/public_html
RewriteEngine On
RewriteCond %{HTTP_HOST} ^1\.2\.3\.4$
RewriteRule ^(.*)$ https://wordcounted.com/$1 [L,R=301]
Assuming your public IP is 1.2.3.4

Related

How to restrict direct access to a folder / location to an specific IP address

O.
This website is like a drug to me.
I am hoping someone can guide me over this task.
I need an script/workaround, in order to restrict direct file access to a folder or a file in specific, and allowing ONLY access to it via pre-authorized IP addresses.
What I would like to accomplish is for a file to be able to be be accessible via an iframe over my website, and only our website, but block any other attempt of visitors to access it directly. Restriction based on IP (adding my website's IP address to the pool of allowed visitors and block everyone else).
www.mysite.com/public/
opens up via iframe www.mysite.com/private/FILEA.html
but www.mysite.com/private/FILEA.html it would not be accesible directly
Is this even possible?
I have been reading S.O for days trying to find a solution.
If anyone can think of a solution I would be eternally grateful.
Thanks a lot guys!
Is this even possible? I have been reading S.O for days trying to find a solution.
Not what you are thinking. You can't restrict by IP because when you put the contents of www.mysite.com/private/FILEA.html in an iframe, it's still loaded by the client's browser, thus the remote IP that accesses it is still the client's IP. You can't deny/grant access via IP.
What you can do, is block access by referer. You can ensure that the referer is www.mysite.com/public/ and only load the FILEA.html file if the request has that referer. However, people can spoof referers and circumvent this, thus still be able to directly access the file if they were persistent. You can do this via some rewrite rules placed in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !www.mysite.com/public/ [NC]
RewriteRule ^/?private/FILEA.html$ - [L,F]
This means if the referer does not contain www.mysite.com/public and if the request is for /private/FILEA.html, then return a 403 forbidden.
Something a bit more complicated would be issuing temporary session cookies when someone visits /public/ and route all requests for FILEA.html through a php script (or some other script) that verifies the session cookie is valid before serving the private file.

Make original site url name to some fake url name

I am new to rewrite site url name. I have a site url like http://66.15.101.250/test/ . this is my owned server link So i want to change this site url to something other name like http://testsite/test/ ( i do not want to give domain name to this ip address url).And i have otheres site running on this http://66.15.101.250/test/ server . I have no idea how to do this, what should i do.
Is this possible through .htaccess file or something else
Thanks in advance
Your server can only respond to requests it receives, and will only receive requests routed to it by DNS, so if you don't own the domain name, you can't receive public traffic directed towards it. You could silently redirect users from
http://66.15.101.250/test/ to the content found at http://testsite/test/ but they would still see the http://66.15.101.250/test/ url in their browser.
If you think about it, its a good thing you can't do this or I could make stealyourcreditcardinfo.com appear as paypal.com. Indeed most uses for what you are asking about would not be legitimate ones...
For your own internal testing purposes, you can make virtual host entry for testsite.com and your server will respond to any requests it receives for testsite.com. You then change your HOSTS file to point testsite.com to 127.0.0.1 and testsite.com will work in your browser, but only on your machine because you manually overrode your own DNS. The DNS everyone else is using is still pointing testsite.com to the actual IP address somewhere else
If you need this for testing purposes (as it seems to me), you can put 66.15.101.250 testsite in your hosts file and configure a virtual host for testsite in your webserver.

How to display content from another domain by editing CNAME records?

I have a site that lets people have their own e-stores, for ex- mysite.com/clientname
What I want is, if somebody opens store.clientname.com or clientname.com/store, the content is pulled from mysite.com/clientname. [ So that their users feel that they are browsing on their site ]
I know this is possible because site'e like tumblr let you do that by changing a CNAME entry for your domain to their IP address.
I do have a dedicated IP address.
Also, can this be done by editing the .htaccess file at clientname.com, and if yes, which method is better/easy?
You'll want to solve the problem in a completely different way for http://store.clientname.com/ versus http://clientname.com/store.
In the first case, you can serve the web site as a virtual host. Just set up a virtual host called store.clientname.com and set its DocumentRoot to be the existing directory that contains the files for http://mysite.com/clientname. If you have other web server configuration directives that apply to http://mysite.com/clientname then you'll also want to apply those in the virtual host. Finally, the client can set up a CNAME record in DNS for store.clientname.com pointing to your web server.
If you are using Apache, you can also use a default virtual host and mod_rewrite to dynamically translate URLs of the form http://store.{whatever}/ to http://mysite.com/{whatever}/. However, this won't work if you are using HTTPS.
In the second case, you don't want to serve the web site at http://clientname.com/ because the client presumably is already hosting that and presumably http://clientname.com/otherstuff has to continue working and come from their server. So the second case is easier for you because all the work has to be done on the client's web server. But it's simple: they will just have to configure their web server to proxy http://clientname.com/store to http://mysite.com/clientname.

How to do a no-DNS site preview, when a wildcard redirect is in place

I'm looking to figure out how to replicate the functionality of GoDaddy's PreviewDNS when I'm moving a site to my own web host based in cpanel.
My setup is this: I have a wordpress multiuser site setup with a subdomain install, and a wildcard redirect.
I can't figure out how I can preview the website for an account before the DNS is switched over to my host from the old host.
I've been able to sorta do this by creating an A record of a subdomain over to my host, but I still have the issue of not being able to test the actual files instead of a copy in a subdomain.
I have two IP addresses attached to the server, one to the server itself and all the shared domains, and the other dedicated to the WP multisite.
When I go to http://ipaddress/~username/, I either get an error, or get redirected to the wordpress multisite's default "this site doesn't exist, sign up now to create it" page. I've tried this with both IP addresses with no avail.
Any ideas?
I think what you're trying to do is ensure that everything is working on the new server before having the DNS globally changed for all users? You could change your local computers hosts file to point the domain (and any subdomains you wish to test) over to the new dedicated IP address, which is essentially moving the DNS over for just yourself.
Here's a pretty good guide on how to do it: http://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

Subdomain mapping to another external subdomain

I'm trying to map help.domain1.com to help.domain2.com. I've seen this on UserVoice. They let you map something.yourdomain.com to something.uservoice.com.
On domain1.com I've set up a CNAME to help.domain2.com.
It works fine but when I open help.domain1.com I get the content of domain2.com instead of help.domain2.com.
After some experimenting I've realized that this is an expected behavior.
So my question is what do I have to do on domain2.com (or maybe on domain1.com?) to have it show content of subdomain "help.domain2.com" when I navigate help.domain1.com?
(I'm using Plesk and the OS is Windows Server 2003)
I was facing the same problem for the last couple of days, and just found the solution...
In /etc/apache2/site-available/default, I had two virtual hosts, first one was for my domain, and the second one was for my sub domain. All I had to do was reverse the order of the virtual host blocks, placing the sub domain in front of the domain, and it worked! :D
I found the solution. One way would be to use a mod_rewrite rule on domain2.com and do a redirect if referrer is domain1.com. Or to assign a dedicated IP address.
HTTP/1.1 uses the Host: header to figure out which site is being requested, should there be more than one site hosted on the same IP address.
You need to ensure that the second (target) web-server is configured to expect incoming HTTP requests with the original URI in them.
I am not 100% sure how to do this in windows but in apache you just need to setup a virtual host to redirect it from the main domain to your subdomain.
you do not say if you are using IIS or apache or what the webserver is.
I imagine that what you need to do is setup a new website in IIS (not a virtual directory) and in the website tab click on advanced and edit the entry in there so that the "host header name" is the subdomain you want.
Jon Hawkins

Resources