Hosts file not working with bindings in IIS - iis

I have added a website to IIS with a binding hostname of richard-danvers.dev assigned to port 80
I have then added an entry to the hostfile with the public ip address of the server and the host name:
51.141.98.202 richard-danvers.dev
I have also tried
127.0.0.1 richard-danvers.dev
this results in ERR_CONNECTION_REFUSED
when I ping the hostname I can see any changes I have made in the hostfile (e.g. 127.0.0.1) but it still does not work when trying to navigate to the site in a browser.
and I have also tried with the actual DNS record I have pointed to the public IP (this returns a ERR_CONNECTION_TIMED_OUT and ping resolves but does not get any successful pings)
none of these seem to allow my website to be accessed. When I enter a binding without a hostname I can hit the website under localhost fine so can't understand what I've done wrong/missed.

Because I am using a .dev domain the ssl certificate had to be set up and configured in the bindings to allow the hostname to be hit.

Related

My IIS website is not working on IP address

I created an IIS website and bound it to both the localhost and my IP.
On localhost, It works fine but I cannot access it from my IP address.
I also tried if there was some problem with port and I found the port 139 working so i binded it to that but still problem continues.
Also, I use mobile hotspot for accessing internet.

Caddy multi-domain reverse proxy

I'm new to Caddy server but their website looked promising. I want to use it as a reverse proxy for the websites that are hosted on other servers. So, I have 2 websites; a Wiki and a photo gallery, that needs to be hosted outside of my local network.
Caddyfile
My Caddyfile is pretty straight forward:
coppery.<my domain name> {
proxy / http://192.168.1.66:80 {
transparent
}
}
wiki.<my domain name> {
proxy / http://192.168.1.88:8080 {
transparent
}
}
When I first started caddy I saw some HTTPS stuff with lets encrypt but that was succesful so now when I start it I get this output:
root#caddy:~# caddy
Activating privacy features... done.
Serving HTTPS on port 443
https://coppery.<my domain name>
https://wiki.<my domain name>
Serving HTTP on port 80
http://coppery.<my domain name>
http://wiki.<my domain name>
WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with `ulimit -n 8192`.
I think for now I can dismiss the warning, I might solve that in the future but this is not a production environment anyway.
Portforwarding and DNS
I configured the domain names to resolve to my IP address (this already worked) and when I ping the domain names, they resolve the IP address correctly.
When I access the IP-addresses directly from my local network it works, I get the websites I expect. So I added some configuration on my router and port forwarded port 80 and 443 to the local IP address of the machine hosting the Caddy server.
Now when I try to access coppery.<my domain name> on either HTTP or HTTPS it's not showing anything.
So my only guess is that there is something wrong with the Caddyfile configuration but it's a realy simple case and all I've done is using the examples I found online. Which don't seem to work.
So the question is: What am I missing to make this work as intended?
The problem was the DNS. Once I configured the domain names in my local host file it worked. So the configuration in my question is all correct.

Change localhost with custom port to a fake domain

I have three localhost site with different port..
localhost:80
localhost:81
localhost:82
I want to make fake domains for each site, instead of type localhost:80 on browser, I would like to use a fake domain (such as www.myweb.com)..
I already tried edit the hosts file in C:\windows\system32\drivers\etc..
I add a line 127.0.0.1:81 www.firstfakedomain.com
to the hosts file
But it doesn't works!
is it any configuration to be made in this box...
In your host file don;t specify port number. Your host file should have entry like like below
127.0.0.1 test1.com.au
127.0.0.1 test2.com.au
In your IIS application specify host name as test1.com.au and test2.com.au for your applications on port 80.
AFAIK, port numbers are not for the host file resolution of domains.
You can do this configuring the fiddler host.
Go to Fiddler2 menu:- Tools > HOSTS
and then modify it for the IP address you want.
127.0.0.1:81 www.firstfakedomain.com
Save it and try this in browser.

URL redirection using powerdns and lua scripting

I am building an internal whitelist browsing filter server for a business.
It is 95% operational.
PowerDNS intercepts the DNS request and the LUA script correctly determines if the URL is whitelisted.
The problem lies in the blacklist block page ... all I get is PAGE CANNOT BE DISPLAYED.
The LUA script is getting to this line but the actual redirect never occurs:
return 0, {{qtype=pdns.A, content="1.2.3.4"}}
The 1.2.3.4 is where I put the actual IP of the PowerDNS server itself.
Apache is not detecting that anything is getting to the server over port 80.
If I navigate to 1.2.3.4 I do get the block page so I know apache is configured correctly and I have ServerAlias set to * to accept all domains.
Thanks in advance.
First of all, you should be sure that domain resolved correctly using something like:
nslookup example.com
Secondary, DNS-cache on the client computer may prevent correct resolving;
You should use 443 port additionaly to 80 for https browser connections;
I have the simular schema with powerdns+lua+nginx and everything work fine.
If you have no connection to the apache, that's mean your browser does not resolve domain correctly.

How can I access a website configured with host headers in IIS on the local machine?

When using host headers to host multiple websites on the same IP address in IIS, is there any way of accessing that website from a browser running on the local machine?
This is normally required when a given web component only allows configuration from the local machine. It's also useful when things like ASP.Net's built in error handling isn't working and you can only view the error in the browser but don't want to allow remote users to see it.
This has baffled me for a while and everytime I come across it I end up giving up in frustration and reconfigure stuff so I can accomplish such tasks remotely.
Added: #Ishmaeel - modifying hosts doesn't seem to help - you either get a 400 error (if all websites have host headers) or whichever site is configured without a host header.
Just an idea: Mapping the hostname to 127.0.0.1 in the hosts ($WINDOWS$\system32\drivers\etc) file may help. This way you should be able to pull up the local IIS site by typing the hostname as if it's a remote server
Maybe I am not understanding the question, but what's wrong with just typing in the URL for the website? If it's the matter of domain name resolution, you can point to the right DNS or put it in hosts file.
eed3si9n -- if you are trying to access a url locally and you use host headers you cant just type in the url: for example you have 2 websites (website1.com website2.com) on 1 server using host headers. the local ip of the web server is 192.168.1.50 --> if you type in 192.168.1.50 you will get a 'page cannot found'. if you put in the url website1.com or website2.com you will be accessing the sites from the outside (not locally).
so the problem is how to access the sites locally not from the outside -- for example i need this ability so that i can access locally as the test sites are only available locally. not from the outside...
You can try telnetting to the server.
$ telnet localhost 80
(type these lines manually)
GET / HTTP/1.1
Host: www.example.com
(exchange www.example.com for the host name your server is mapped to)
I would assume the only way you can do this is assigning a custom port to the specific website you want to monitor and just access it as "localhost:CustomPort".

Resources