2

I'm trying to add my machine's LAN IP as a 'failthrough' location to use in the event the main server has issues.

Lately, my main server name (i.e. https://myserver.domain.com) has been having some issues due to LetsEncrypt certs issues, so any URL running on my server using that domain name fails as well. What I want is to have Nginx automatically pass it to the machine's IP instead if it detects the domain name itself is down.

I'm using the Docker LinuxServer LetsEncrypt container, and I've tried just adding the IP to the server_name variable in the config, but after restarting the container, nothing appears to change when trying to navigate to https://myserver.domain.com (it still just gives the same error page instead of redirecting to the IP).

Here's the current config with the issue:

server {

    listen 443 ssl http2 default_server;

    root /config/www;
    index index.php index.html index.htm;

    server_name myserver.* 192.168.0.194:3333;

    # enable subfolder method reverse proxy confs
    include /config/nginx/proxy-confs/*.subfolder.conf;

    # Tell search engines not to crawl/add this domain
    add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";

    # all ssl related config moved to ssl.conf
    include /config/nginx/ssl.conf;

    # enable for ldap auth
    #include /config/nginx/ldap.conf;

    client_max_body_size 0;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
}

Note this line in particular; the IP as the second server is the intended failthrough IP:

server_name myserver.* 192.168.0.194:3333;

Also note: if I just use https://192.168.0.194:3333 directly in a browser, it navigates to the intended page fine, so this has to be something config-wise with Nginx that I'm trying to solve. It seems like a pretty simple issue, but I'm not super familiar with Nginx config nuances yet.

1 Answer 1

0

It sounds like you want nginx to redirect to another URL if it determines the domain to be "down", however this configuration would be serving requests based on the initial domain name being up (that's now the request reached nginx).

You could investigate HTTP Load Balancing which also supports Health Checks for upstream servers:

monitor transactions as they happen, and try to resume failed connections. If the transaction still cannot be resumed, mark the server as unavailable and temporarily stop sending requests to it until it is marked active again.

upstream backend {
    server backend1.example.com;
    server backend2.example.com max_fails=3 fail_timeout=30s;
}

However this would work based on failed requests to the upstream server, which I don't suspect is your issue. Paragraph 2 of your question needs to be clarified. What kind of cert issues are you seeing, and why can't they be fixed?

With the currently provided info, it sounds like this is not a task to be done at the nginx level.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .