4

Is there anybody who tell me why i still got error like this?

Restarting nginx: [emerg]: unknown "domain_name" variable
configuration file /etc/nginx/nginx.conf test failed

the part of code where is variable looks like:

server {
    # if you're running multiple servers, instead of "default" you should
    # put your main domain name here
    listen 80 default;

    # you could put a list of other domain names this application answers
    server_name ^~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;

    # root defined by domain
    root /home/deployer/apps/$domain_name/current/;

    # access && error && rewrite log
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    rewrite_log on;

    # default location
    location / {

...

1 Answer 1

6

Remove the "^". From

server_name ^~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;

To

server_name ~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;

Or switch "^" and "~". The letter "~" must be the first one.

server_name ~^(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;
Sign up to request clarification or add additional context in comments.

1 Comment

Nginx failed to restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.