Nginx: [Emerg] Unknown Directive " " in /Etc/Nginx/Sites-Enabled/Example.Com:3

nginx: [emerg] unknown directive in /etc/nginx/sites-enabled/example.com:3

I had the same problem which was that I copy/pasted the config code from the web and some dirty EOL(end of line) characters where there.

The editor didn't show them, but nginx treated them like a directive.

Just deleted every EOL and added again.

Unknown directive in /etc/nginx/sites-enabled/example.com + HttpUploadProgressModule

Something apparently causes the nginx config parser to fail working properly.

The regular expressions with named backreferences drew my attention.
Nginx is using the PCRE library to parse regular expressions, so this should be valid syntax

See this to understand capturing groups and named/unnamed backreferences
http://regular-expressions.mobi/named.html

Try this

location ~ (.*)/x-progress-id:([0-9]+) {
set $upload_form_uri $1;
set $progress_id $2;
rewrite .* $upload_form_uri?X-Progress-ID=$progress_id;
}

Same meaning but a bit more basic syntax.
If this does not help, more investigation will be required.

nginx: [emerg] unknown directive server in /etc/nginx/sites-enabled/default:1

Well. After letting this question be on Stackoverflow for some time I tried to spin up Virtual Machine on my computer. Create a config file with the exact same content. Copy paste from my Windows machine to my linux machine. Uploaded the file to my linux server and it worked.

So in short Windows screwed with the content of the file without I was able to see anything. I have uploaded a working version of the file here:
https://s3-eu-west-1.amazonaws.com/topswagcode.dev/default

Restart nginx: unknown directive listen

The listen directive from the following file

my /etc/nginx/sites-enabled/react-flask-app.con

Should be

 listen 80;

Yours has :

Why is nginx complaining of an unknown directive?

Actually you have another error. I've checked your server block and got following:

$ sudo nginx -t
nginx: [emerg] invalid URL prefix in /etc/nginx/sites-enabled/test:23
nginx: configuration file /etc/nginx/nginx.conf test failed

This is error about missing protocol in proxy_pass localhost:8000; line. After fixing it to proxy_pass http://localhost:8000; configs test passed.

Probably you're looking into old (or wrong) error log.

Nginx with Docker : nginx: [emerg] unknown directive enable in /etc/nginx/nginx.conf

Read the error message:

2021/06/13 20:22:46 [emerg] 1#1: unknown directive "enable" in /etc/nginx/nginx.conf:45
nginx: [emerg] unknown directive "enable" in /etc/nginx/nginx.conf:45

You have an syntax error in your config file #45
The configuration file you have shared looks good on line 45 in genera as your "enable sticky session" is commented out with the # sign.

Make sure the configuration file in your running container is the identically by typing

docker exec nginx /bin/bash -c "cat /etc/nginx/nginx.conf" | tee nginx.co.conf

on your digital ocean server. Please share the output of the nginx.co.conf file and make sure line 45 is commented out as well.

How did you deployed the docker-container? Did you exported them as tar and uploaded them so the new server?? Sounds like you have some differences in between your local container and that one on digitial ocean.

How to resolve Nginx error nginx: [emerg] unknown directive server in conf:1?

I found the problem, is windows notepad saved using BOM format, using vscode to re-select no bom format UTF-8.



Related Topics



Leave a reply



Submit