Access site with localhost and host name - asp.net

I have a site in IIS.
I defined a binding with host name "aaa.com".
My question is how do I access 'http://localhost' and have it refer to the same path as http://example.com which works?

Try editing you hosts file
open the file (it's probably in C:\Windows\System32\drivers\etc)
find the following line:
# 127.0.0.1 localhost
and change it to
127.0.0.1 aaa.com

Related

What's the exact meaning of "ng serve -- host any_name"?

If we put an IP and host mapping in /etc/hosts file, then if we access the website using the hostname, we get redirected to that IP instead. But when I do this:
ng serve --host any_name
What is this doing? Setting host means what exactly? Does the host provided here have any relation to the host in /etc/hosts file?

Why does changing the fully qualified domain name in /etc/hosts not update the fully qualified domain name?

I am running Ubuntu 18.04 in a VM. When I check the hostname using hostname or the fully qualified domain name using hostname -f, hostname --fqdn or hostnamectl I get the default ubuntu for each. I want to permanently update the hostname to host and the fully qualified domain name to host.okd.dns.
I have changed the file /etc/hostname to include only the name host. I have also changed the file /etc/hosts to appear as follows (excluding IPv6 hosts):
127.0.0.1 localhost
127.0.1.1 host.okd.dns
After saving and rebooting the VM, when I check hostname it returns host as expected, but when I check the FQDN using hostname -f, hostname --fqdn or hostnamectl it also returns host only without the .okd.dns appended to it as I would expect.
There seem to be several methods of updating the FQDN for Ubuntu 18.04 and I have tried most of them, including this method, which seems to be the most common. What do I need to do to get the changes to the FQDN to update and stick?
Apparently, I needed to add host after host.okd.dns in the /etc/hosts file. I was sure I had tried this in the past, but perhaps there was some other error I had made somewhere and this wasn't reflected. Once doing this and after a reboot, hostname -f and hostname --fqdn both return host.okd.dns as expected.

nginx enables https on port 80 and 8080 only

I know almost nothing about nginx, please help me to see if it can be achieved ?
A public network IP with only 80 and 8080 ports open, Such as 182.148.???.135
A domain name with an SSL certificate, Such as mini.????.com
This domain name can resolve to this IP.
Using the above conditions, how to enable https ? So that I can pass visit https://mini.????.com to the target server 182.148.???.135
Thank you very much for your help!
Just came accross an issue. Doesn’t matter if its a local setup or one with a domain name.
When you create a symbolic frpom sites-available to sites-enabled you have to use the whole path to each location.
e.g. you can’t
cd /etc/nginx/sites-available/
ln -s monitor ../sites-enabled/
It has to be:
ln -s /etc/nginx/sites-available/monitor /etc/nginx/sites-enabled/
Inside /etc/nginx/sites-available you should have just edited the default file to change the root web folder you specified and left the server name part alone. Restart nginx, should work fine. You don’t need to specify the IP of your droplet. That’s the whole purpose of the default file.
You only need to copy the default file and change server names when you want to set up virtual hosts.

Tunnel a localhost subdirectory through ngrok?

Objective: want to share a website preview using ngrok, which creates a tunnel from which my localhost can be seen with an url of something like mywebsite.ngrok.io
Problem: I use WAMP and my localhost folder looks something like this:
localhostdirectory
|-- website1
|-- website2
|-- etc
To access a website I type to localhost/website1/ in the browser, I would like to tunnel only that URL, the possible solutions would be:
Setting up a Virtual host, I would go through the hassle of manually setting up a virtual host, then I get something like website1.dev, and then I would pass it to ngrok as the host header in the HTTP request, like that:
ngrok http -host-header=website1.dev 80
I didn't understand what the host header is though, and why can't I pass a relative url like localhost/website1/, also what is the rewrite option?
Change the folder directory of my localhost to the folder of the website, I would prefer not to do that.
Is there a better way to accomplish my objective in an easier way, maybe going through WAMP aliases?
If you make do with Apache Vhost you just have to exec command
ngrok http -host-header=rewrite YOUR-LOCAL-DOMAIN:PORT
Dont forgot to edit host file for resolution #IP <-> YOUR-LOCAL-DOMAIN
I tried below way.
When I ran $ ./ngrok http 80 ngrok listen to localhost:80 which shows dashboard because apache server is running on port 80. Then I tried running subfolder in another port, which solved problem. Assume you have project in xyz and want ngrok should points it. Then do following
$ cd /opt/lampp/htdocs/xyz
$ php -S localhost:8080
Here 8080 is any unused port. localhost:8080 direct points to xyz and then open other terminal
$ ./ngrok http 8080
By doing this ngrok will listen to 8080 port were your xyz is running.
Hope this helps!!
After you set up the ngrok address to point to localhost on port 80, you can access your websites by their names.
Ex:
ngrok http -subdomain=dev 80
Access website1:
dev.ngrok.io/website1
I believe the correct syntax now for ngrok v3 is ngrok http --host-header=rewrite YOUR-LOCAL-DOMAIN:PORT
Notice the double --
https://ngrok.com/docs/guides/upgrade-v2-v3

Accessing nginx on a virtual machine from another computer

I am currently following a tutorial on using chef. The teacher uses vagrant to set up a virtual machine, his vagrant file contains this:
config.vm.network :hostonly, "33.33.33.10"
I didn't want to use vagrant, so created a VM from scratch and implemented all the other parts of his vagrant file manually. However I'm not quite sure what this exactly does. He then goes onto updating his hosts file in /etc/hosts to include:
33.33.33.10 kayak.test
Then he can access his nginx server using "kayak.test" in his browser on another computer. I can access my server using my private IP address "192.168.169.129" in the browser, but I added this that name to my hosts file and I can not access it in the same way. My host file now looks like this:
127.0.0.1 localhost
127.0.1.1 jack.www.jack.co.uk jack
192.168.169.129 jack.test
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
But I cannot access jack.test in the browser of my other computer. What do I need to do to get the same functionality as he has?
Thanks,
Jack.
Probably this issue related to Avahi if you have it on your system.
RFC2206 explicitly defines .test .example .localhost an other TLD's as invalid:
http://www.rfc-editor.org/rfc/rfc2606.txt
As a possible workaround you can change the line in /etc/nsswitch.conf this way:
hosts: files mdns4_minimal dns mdns4
Do not forget to restart avahi daemon after this.
Source of the workaround: http://avahi.org/wiki/AvahiAndUnicastDotLocal
Thanks #AndreySabitov you made me see where I was going wrong.
I was getting confused and updating my servers /etc/hosts file, rather than my laptops. Therefore when I updated my laptops etc/hosts file with
192.168.169.129 jack.srv
I can now access that server from my laptop.
Thanks!

Resources