Score:-1

Nginx need to edit etc/hosts file

de flag

I using docker-compose to run python app, In that I have a service as nginx. Currently I am using server_name localhost; and it is running fine. Now instead of localhost I am trying to use domain name eg www.example.com on my local system. So I edited nginx conf as server_name www.example.com. It didnot worked, On googling I found that I need to add this name to /etc/hosts file. I found few egs as below:

-A

127.0.0.1 localhost www.example.com

-B

127.0.0.1 localhost
127.0.0.1 www.example.com

I am new to devOps.

Questions:

  1. Is it mandatory to edit /etc/hosts file. Can we achieve without this?
  2. Which way is preferred way A or B?
  3. After doing above stuff, If I want to deploy on cloud, Do I need to configure anything more with respect to domain name?
Score:1
cn flag

Ususally you should use DNS, not hosts file.

To access the web sites by one of the server_name, you need to configure hosts file on you local machine, more precisely, the machine where you are running the web browser. If it's your Windows laptop, this is %SystemRoot%\System32\drivers\etc\hosts, which usually maps to C:\Windows\System32\drivers\etc\hosts. In this file you should have an entry like:

192.168.1.123 www.example.com

Where 192.168.1.123 is the IP of your web server. Make sure that IP is reachable from your web browser machine.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.