开发者

How to add entry in windows "host file" such that it can redirect over https

开发者 https://www.devze.com 2023-01-07 10:54 出处:网络
I want to redirect all my browser request to abc.com when a request is sent to xyz.com I was able to do this by adding an entry in the hosts file under windows.

I want to redirect all my browser request to abc.com when a request is sent to xyz.com I was able to do this by adding an entry in the hosts file under windows.

However I see that i can go to http://abc.com when i type in http://xyz.com:8080 but I cannot seem to get the same redirection over https.

I found out that you cannot mention ports in the h开发者_如何学Pythonost file. Need some help on this


HTTPS is specifically designed so that you can't do this - not only is one of the core points of SSL/TLS that the conversation be encrypted, it also ensures that you really are talking to who you think you are, that you haven't been redirected to a fake site via DNS.


That's not what the hosts file is for. It's about the hosts that you are referring to. abc.com and xyz.com are hosts.

All the hosts file does is associate a host name with an IP address. Nothing else is possible.


Get a clone of the part you need from the genuine site.. put it on local iis, add ssl binding using self signed certificate and add entry to hosts file.http://www.selfsignedcertificate.com. if you are in rush with no time to play with iis mgr use appcmd.

Youll get a not verified warning for untrusted issuer.. add it to trusted root cert authorities. http://www.robbagby.com/iis/self-signed-certificates-on-iis-7-the-easy-way-and-the-most-effective-way/

Never tried self signed cert tho.. let us now how your testinggoes.


A hosts file is DNS, which is used to resolve a domain name to an IP addresses, which has nothing to do with ports.

If you redirect from https://abc.com to https://xyz.com then they will need to be different servers with different certificates, as an SSL certificate is bound to the domain name.

Which means if you use your hosts file to lookup the ip address of abc.com when you try https://xyz.com then it wont work as the certificate will be for abc.com and wont match the hostheader https://xyz.com sent by your browser.


If you are using windows command for routing:

netsh interface portproxy add v4tov4 listenport=listen_port listenaddress=any_free_ip_address connectport=localhost_port connectaddress=127.0.0.1

The default port for http request is 80 so if one is using https use 443 as it is the default for https


With HTTPS, it'll be to do with the security certificate - likely you can't get around that, or at least ... I hope not.


Putting an entry in your hosts file only associates your human readable host name with an ip address, the rest happens in the application that makes http requests.

parts of uri on wikipedia: https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/URI_syntax_diagram.svg/1068px-URI_syntax_diagram.svg.png

When ever an application makes a request for a resource, let's say your browser, turns what you type for address into a proper uri, which includes scheme.

If you don't type https, or leave the scheme out, you get http. You end up still getting https for some sites, because they use ssl redirection, maybe something like this: https://www.linkedin.com/pulse/how-use-nginx-reverse-proxy-https-wss-self-signed-ramos-da-silva/?articleId=6678584723419226112


Use nslookup xyz.com and get IP

then put this IP to hosts (/etc/hosts in Linux)

the https domain name must transform to IP from

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号