I would like to ask, can anyone here advise on how to have a specific web address enabled to display only at a specific IP address that I choose?
I've only got HTML basics, and nowhere have I found a way to get this or are there any storage sites that support this?
I want it for storing a script I don't want to have publicly and I need it fixed to an IP address.
javascript:$.getScript('secret url);void(0);
Thank you
You will need to blacklist all other IPs and whitelist the IPs you want it to have access to.
Shared Hostings will have their own GUI for doing this but if you're hosting your app using a VPS (Virtual Private Server).
The most common approaches are:
Option #1: Through Web Server (Nginx, Apache, etc...)
Nginx
https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-proxied-tcp/#restricting-access-by-ip-address
Apache
https://httpd.apache.org/docs/2.4/howto/access.html
Option #2: Through Backend Server (PHP, Ruby, etc...)
PHP IP Address Whitelist with Wildcards
Note:
You will need to have your HTML page rendered using one of these
approaches to make it work.
The flow would look like this:
User visits the page -> Web Server Checks If the IP is allowed ->
Backend Server Checks if the IP is allowed (optional) -> Serve the
HTML.
Related
Since I am using a host header filtering technique in my ASP.NET MVC application, I would like to prevent users from browsing directly to the IP address of my site, and force them to use the FQDN. Is this possible?
I see similar SO question here with no answer
You can do this with Bindings in IIS (assuming you're using IIS): https://technet.microsoft.com/en-us/library/cc731692(v=ws.10).aspx
Open IIS
Right click your site
Click "Edit Bindings"
Edit the entries (http/https) to include a "Host Name" (ex. "YourSite.com", "sub.YourSite.com", etc...)
An alternative would be to force a redirect to the FQDN in your code. You should be able to determine the url using a ServerVariable: https://msdn.microsoft.com/en-us/library/system.web.httprequest.servervariables(v=vs.110).aspx
You can add another Website in IIS, locate it to an empty directory to make it don't do anything useful, use 80 port but don't bind any hostnames. In this case, who access your server by IP directly would just hit this Website, they won't bother you anymore.
Or maybe you can put some helpful webpages in this website to help your client visit by domain name correctly.
I have a Linode server operating under a single IP Address. I access various websites via the single IP addresses in the following format: http://x.x.x.x/mysite1
Is it possible to access my individual websites, mysite1 etc, via names set in /etc/hosts?
In /etc/hosts I tried setting:
x.x.x.x dev.mysite
But, attempting to access my website via http://dev.mysite results in a webpage not found error.
Is what I'm trying to accomplish possible?
As long as you have made the /etc/hosts modification on the machine that is trying to access the website, then yes this is possible. Although you will also have to modify your Apache config so it knows which website to display when "dev.mysite" is requested. My Apache knowledge is rudimentary but I believe you want VirtualHost for this.
If you want other people to access the website without modifying their hosts file, you will need to buy a domain. For instance, if you buy xyz.com, you can put your sites under site1.xyz.com, site2.xyz.com and so on.
I believe Your /etc/hosts needs no change . dev.mysite already points to mysite.com which has an entry in /etc/hosts
You need to modify your web server (nginx / Apache)listening in port 80 to accept requests on dev.mysite
I'm having trouble finding info on this one, even having access to my company domain controller I still can't see what configuration is causing the same behavior I want to mimic on my home server.
I'm working from a test environment on my home PC and would like the following behavior. Note that I do not require any of these sites be accessible anywhere but my local machine, again, I just want to learn.
My Goal:
To configure IIS to host multiple sites, accessible via "aliases" which map to different ports. For example:
home -> localhost:81
test -> localhost:82
dev -> localhost:83
Furthermore, I want the url in my address bar to actually BE what it says on the left, not simply redirect, BLEH! So if I type "home/" in my address bar, it should load the page at "http://home/".
How can I achieve this? Thanks... ;)
Here's what I have configured in my bindings for the site so far, but no cigar...
first you need to edit your hosts file (probably C:\WINDOWS\System32\drivers\etc) so that you resolve home for example to localhost, add records like this:
127.0.0.1 home
127.0.0.1 test
...
Then you should be able to set up your IIS site with the Host name as home, but leave the port to the default of 80.
When I create a site in IIS I select for IP "All Unassigned" and then make a unique port.
I access my sites via the outside world like this:
http://mbdev.myftp.biz:8004
http://mbdev.myftp.biz:8006
Those all go to demos sites.
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.
I want to change my hosts file to redirect a web address to my site...
normally I would just do... ping mysite.com then in the hosts file, if the IP came out as 99.99.99.99, I'd write...
99.99.99.99 siteiwanttoredirect.com
But in this case my site is on virtual shared hosting... which means the IP I get back from the ping is the same as a few other sites and if I type that IP in the address bar, www.mysite.com won't come up. Here's a bit more details: someone who asked a question about why pinging it wouldn't give the correct IP.
So what I would like to know is... if you're on virtual shared hosting, how can you specify redirects to your site in the hosts file?
Thanks,
Matt
You cannot. With the hosts file you can change the IP address, but your shared hosting provider needs the HTTP Host header to be set up correctly -- which in your case will still be siteiwanttoredirect.com and not mysite.com . Your hosting provider will therefor not know who's site to show.
What you could do is redirect to some host you control (f.i. localhost) and run a proxy server there. If you set up Apache on your machine, with a virtual host for siteiwanttoredirect.com which does a reverse proxy to mysite.com , it should work.
This is handled via the host header of the website, and not anything on your local machine, like your hosts file.
I would make sure your host has that set up, then as long as people visit your sit via the website name, and not IP, everything should work.
On a shared host, the website you get is determined by the domain name you ask for thanks to the Host HTTP header. For this to work properly the web server needs to be configured correctly so it knows what website to serve in response to which Host request - this is usually called 'Add-on Domains' on CPanel driven shared hosting.