Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx config example causes [emerg] error unexpected "}" in nginx.conf:40 #1389

Open
cidrbl0ck opened this issue Jul 18, 2024 · 2 comments
Open

Comments

@cidrbl0ck
Copy link

cidrbl0ck commented Jul 18, 2024

Summary

  1. Going thru the latest docs to setup a trio of Linux hosts with a separate host for the Load Balancer. The hosts were all complete, moved onto the LB section and used the example config shown here. A subsequent 'systemctl restart nginx' fails with:
    Jul 18 16:10:56 eau-rancherlb01 nginx[51925]: nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:40 Jul 18 16:10:56 eau-rancherlb01 nginx[51925]: nginx: configuration file /etc/nginx/nginx.conf test failed Jul 18 16:10:56 eau-rancherlb01 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE

  2. I am also not positive, based on this example, what value is required by <rancher UI URL>, like does it want the actual properly formatted url (https://rancher.domain.com), or the short version (rancher.domain.com)?

  3. Lastly, since the stream module is required, unless you compile from source dont you have to include a load_module line? I did but thought perhaps including that is worth the mention.

At any rate the config as presented has got to be correct.. in so far as the proper number of curly braces but I'll be damned if I can figure this out. Obviously I have removed line 40 to be greeted with the error now being on line 41 for the next brace. This might be a legit Nginx issue but even if so the documentation should be corrected.

nginx version: nginx/1.18.0 (Ubuntu)

root@rancherlb01:/etc/nginx# cat nginx.conf
load_module modules/ngx_stream_module.so;
worker_processes 4;
worker_rlimit_nofile 40000;

events {
    worker_connections 8192;
}

stream {
    upstream rancher_servers_http {
        least_conn;
        server 10.10.16.32:80 max_fails=3 fail_timeout=5s;
        server 10.10.16.33:80 max_fails=3 fail_timeout=5s;
        server 10.10.16.34:80 max_fails=3 fail_timeout=5s;
    }
    server {
        listen 80;
        proxy_pass rancher_servers_http;
    }

}

http {

    upstream rancher_servers_https {
        least_conn;
        server 10.10.16.32:443 max_fails=3 fail_timeout=5s;
        server 10.10.16.33:443 max_fails=3 fail_timeout=5s;
        server 10.10.16.34:443 max_fails=3 fail_timeout=5s;
    }
    server {
        listen 443 ssl;
        ssl_certificate /etc/ssl/acme/fullchain.crt;
        ssl_certificate_key /etc/ssl/private/rancher.domain.net.key;
        location / {
            proxy_pass https://rancher_servers_https;
            proxy_set_header Host rancher.domain.net;
            proxy_ssl_server_name on;
            proxy_ssl_name rancher.domain.net
        }
    }
}


@btat
Copy link
Contributor

btat commented Jul 18, 2024

proxy_ssl_name ...

I think this line in our example is missing the ending semicolon, which may be the culprit for the unexpected "}" error.

For the other points, I'll defer to others.

@cidrbl0ck
Copy link
Author

I'm no Nginx expert but all the examples for.. really any proxy/web host config has no semi colon for the very last line. Guess it doesn't mean it won't work with one. Which turned out to be true.. I just added the semi colon and F me it's started.
No one feels like a bigger idiot than yours truly.. but yeah I guess I'll be the dumb one if only to point out the missing semi-colon in the example.

Here's hoping the other uncertain parts can be tackled as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants