Send Host header when accessing IP address in Firefox - firefox

This isn't really a programming question but more about programming and testing tools.
Is there a way to get Firefox to send the header
Host: mydomain.com
when accessing a page at
http://ip.address.goes.here/
so that Apache can route it to the correct VirtualHost?

You can add the host name and ip-address to your hosts file.

Have you tried the Modify Headers Firefox extension?

If you are creating a site and wish to map the host header to an IP (perhaps your local dev box) for testing purposes, then you should consider editing the hosts file instead.

Just setup an entry in the hosts file. Always worked for me :)

I guess you could use the TamperData extension to manually add it each time.

Related

I changed hosts file but can't see effects

I have to reach the wordpress platform installed by a certain hosting service, so I can build a new website (that will replace the old one), on a certain IP address. I changed my hosts file under their instructions. I put in it the IP address that they had given me and the website domain (separated by a single space). The hosts file hasn't any extension and it's in the right location (System32/drivers/etc - I'm on Windows 8). I cleaned browser and local DNS cache but nothing change: if I put in the browser the url they had given me (www.domain.com/?hostingname) I see the old website, not the wordpress platform. I tried to ping the domain and it returns a different IP address. What can I do? Thanks everyone in advance.
Ok, I solved. It's important to edit the hosts file with Windows Notepad and not with Notepad++

Way to open localhost with different URL

I have tried http://localhost/projectname and http://127.0.0.1/project_name to open my Project in LocalHost
but
I want to open this with some other URL so user can not able to know that I have opened with localhost.
Edited:
My Users currently accessing my project with localhost but now i
want to use some static string to open as url. I mean if currently
users accessing project with localhost/proj but i want to do like
staticString/proj Is it possible?
Is there any way to open project with different URL rather than localhost?
Thanks.
You have to Configure first Virtual Host in your XAMPP or any Web server.
After you can use that name instead of Localhost or IP Address.
Follow this link to configure Virtual Host.
http://sawmac.com/xampp/virtualhosts/
and this also
http://foundationphp.com/tutorials/apache_vhosts.php
You can make use of virtual host configuration in your web server.
Edit your hosts file to include 127.0.0.1 thisismyhost.com
Then can should be able to access your project using thisismyhost.com/my_project
I follow solution of accepted answer but I found one tricky Magic solution for that which i can use without any configuration:
You can use yourString.google It will directly open you localhost.
For Example: Open this link in your browser: pratik.google/
if you have installed xampp it will open your localhost
Really amazing magical trick.
I don't know how it works, May be this is functionality of browsers.
I believe what you are looking for is local tunnel
Use node and npm to install it globally using npm install -g localtunnel
then give the port you want to export lt --port <port>
you will get a link you can share anywhere and anyone can access your localhost site. there are multiple ways and options to it. you can view about it - here!
if you change the port you will see the result like this
> http://localhost:5906/projectname/abc.aspx
right click on the project click on properties and there will be one option web in that change the specific port
hope this may help

Local URL IP redirect via port

I do a lot of custom web development and I am looking for a solution to a problem with testing.
I have a local development server that I run sandboxed environments on. When I need to test something I sometimes will edit my host file to make the domain point at my local IP
In my host file I would have.
127.0.0.1 mydomainname.com
What I would rather be able to setup is if I added a port to a URL:
mydomainname.com:7777
That would then redirect to my local IP
Something like this
127.0.0.1 *:7777
Is this a pipe dream or doable in someway?
You can use Firefox Extension Server Switcher
This firefox extension is a tool for web developers and allows switching between sites on your development and live servers; it helps you to see difference immediately.
It's more easy in use than host file.

Switch firefox to use a different DNS than what is in the windows.host file

For example, I have a development site on a different server but I'm trying to copy content over from the live site so it'd be handy to have the live site in IE and the dev site in FF.
I tried FoxyProxy but I can't seem to get it to work.
I use this to override system's DNS with localserver
in about:config
change this value:
network.dns.forceResolve
network.dns.ipv4OnlyDomains
network.dns.localDomains
with IP address of local DNS server (for exsample 192.168.1.88)
Sorry for my english
It's now possible, with the DNS over HTTPS function:
Open Options, General, scroll to very bottom and open Network Settings,
On the very bottom, you can find DNS over HTTPS:
You had to use about:config before to change this setting, here's for documentation:
Type about:config in firefox address bar.
search for:
network.trr.uri
You can use one of the DNS servers below:
Cloudflare: https://cloudflare-dns.com/dns-query
Google: https://dns.google/dns-query
Secure DNS EU: https://doh.securedns.eu/dns-query
Quad 9: https://dns.quad9.net/dns-query
And set network.trr.mode to 1
Hijacked from here:
https://www.ghacks.net/2018/04/02/configure-dns-over-https-in-firefox/
It appears from your question that you already have a second set of DNS servers available that reference the development site instead of the live site.
I would suggest that you simply run a standard SOCKS proxy either on that DNS server system or on a low-end spare system and have that system configured to use the development DNS server. You can then tell Firefox to use that proxy instead of downloading pages directly.
Doing it this way, the actual DNS lookups will be done on the proxy machine and not on the machine that's running the web browser.
DNS resolving is usually done at the system level and not at the application level, so you can't normally have one program use one dns and another program use a different dns. I'm not aware of any firefox extensions that allow you to use a different dns.
What about having different names for your dev and prod servers? That should avoid any confusions and you'd not have to edit the hosts file every time.
I am using the SwitchHost extension exactly for this problem:
https://addons.mozilla.org/en-US/firefox/addon/14258
It is easy to configure, and even more easy to switch hosts.
I wonder if you could write a custom rule for Fiddler to do what you want? IE uses no proxy, Firefox points to Fiddler, Fiddler uses custom rule to direct requests to the dev server...
http://www.fiddlertool.com/fiddler/
Since http proxy protocol is similar to raw http protocol, you can redirect desired traffic to your development server by telling firefox it's a proxy server.
two limitations:
A. this won't let you use https connections.
B. some frameworks (e,g: wordpress) don't like this method and redirect the request the wrong way
just copy the following code into a .pac file (enter your site domain and IP address, of course), and switch development/production just by changing proxy configuration.
function FindProxyForURL(url, host) {
var prox4site = {
"mysite.com":"PROXY 10.0.1.100:80",
"www.mysite.com":"PROXY 10.0.1.100:80"
}
return prox4site[host] || "DIRECT";
}
Go to options->Advanced->Network->Settings->Automatic proxy configuration url and enter 8.8.8.8 All you Mozilla traffic uses Google dns now.

Difference between specifying IP in host file vs using IP directly

Is there any difference between the following when a intranet URL in accessed in IE
Add an entry in drivers/etc/host file for a name and IP
vs
Use IP directly
e.g. it works with the following link if I have a host entry as (XYZ 10.0.10.200)
http://XYZ/SiteDirectory/ABC/Default.aspx
but when I tried to use IP instead of name
http://10.0.10.200/SiteDirectory/ABC/Default.aspx
It gives me 404 not found error
Yes, there's a difference.
The web server is using HTTP/1.1 and "shared virtual hosting". When the client connects it sends an additional Host: header which contains the hostname part of the URL that the user supplied.
The web server looks at the header to find out which virtual host's data to serve.
In this case, the web server is configured to recognise and serve content from the "XYZ" domain, but doesn't know about any domain called 10.0.10.200
Smells like the webserver is using virtual hosts, so that it serves different pages if the client went to "www.foo.com" or "www.bar.com", even though they have the same IP-address.
As far as I can see there should be no difference. With a host name the order is hosts file before DNS so it should be used.
Is there another line in the host file with the same hostname?
What happens when you do a tacert? (trace route)

Resources