S
S
Sergey Goryachev2020-02-16 23:23:25
Nginx
Sergey Goryachev, 2020-02-16 23:23:25

How to make dnsmasq and nginx friends?

I installed dnsmasq in order to move in development from accessing projects by ip + port to domain names.
Registered in dnsmasq.config

listen-address=127.0.0.1
address=/dev/127.0.0.1


in nginx/sites-available/project_1
server {
  listen 80;
  listen [::]:80;
  server_name *.project_1.dev;


project_1.dev pinged
In the browser 127.0.0.1 - opens the site project_1
In the browser project_1.dev - does not open anything (ERR_CONNECTION_REFUSED)

What to do? Where to look?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2020-02-17
@SergeGoryachev

.dev has been out of business for a long time. since this zone became a valid tld managed by Google.

S
Sergey Sokolov, 2020-02-16
@sergiks

With an asterisk in the initial config, a 3rd level domain is expected. Type in the browser, for example, www.project_1.dev- it should work without changes in the config.
Instead of server_name *.project_1.dev;
necessary server_name .project_1.dev; (still the same, but without the asterisk)
This will be equivalent server_name project_1.dev *.project_1.dev;
See the documentation of the ngx_core_module module -  server_name

A
Alexey Dmitriev, 2020-02-17
@SignFinder

look in /etc/resolv.conf
, this is where the system DNS servers are registered, which nginx also uses.
You need to replace the existing ones with 127.0.0.1 - then everything will go through dnsmasq.
In general, instead of dnsmasq, they could simply use static entries in /etc/hosts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question