7
7
7761662019-12-16 12:11:37
Nginx
776166, 2019-12-16 12:11:37

At the time of launching nginx, the network is not yet available. How to decide?

When restarting the server, judging by the logs

nginx: [emerg] host not found in upstream "example.com" in /etc/nginx/sites-enabled/example.com.nginx.conf:30

the network is not fully initialized, or whatever. If you wait a bit, then it normally starts without this error.
In nginx itself, there is such a construction, where the error is triggered just on proxy_pass:
location / {
        proxy_pass https://example.com:666;
        proxy_set_header        Host    $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }

The task is to start at any cost. Do I understand correctly that a good strategy would be to use upstream and put parameters like max_fails and fail_timeout there? (or even don't set it) Because I don't want to set nginx launch re-kick in cron's @reboot. This does not cause a positive response in my soul, but plunges me into the abyss of despair and disappointment.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
paran0id, 2019-12-16
@paran0id

Add to the nginx unit file in the unit section:
After=network.target

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question