Nginx log error

After launching “bench setup nginx” i get error “unknown main log format” on nginx service .

Deactivating the access log (just comment the line on nginx.conf) it works. But will broke again after executing bench setup nginx …

Frappe v14 and Ubuntu 22.04
Any ideas?

Thanks

Oh, you brave and adventurous v14 pioneers; I salute you! :superhero:

Can you paste or screenshot the portion of 'nginx.conf' that you commented out, and tell me what version of Nginx you’re using?

1 Like

The log_format is missing.

in /etc/nginx/sites-enabled/frappe.conf should include as following

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

Add the format above server { }.

6 Likes

The log_format is by default in nginx.conf under the http block

You donot need to specify them in frappe.conf and if you need to specify , it needs to be under http block

1 Like

The log_format is missing in frappe.conf (only exist in frappe-bench/config/nginx.conf) when I installed new v14 for development. I might miss something during installation.

It should be done.

sudo ln -s ./config/nginx.conf /etc/nginx/sites-enabled/frappe.conf

1 Like

Thanks to everyone. :wink:

what worked for me was :
sudo bench setup production <user>

I’m using this solution but it doesn’t work for me.
Symlink is creating but when restart nginx it gives error.

frappe.conf file showing in red color.

Can you check in sites-enabled? Does it have as below?

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

No. nothing like it in frappe.conf.
What should I do?
and If I have to place this code in frappe.conf, So where I should add it in frappe.conf?
Please guide me.
Thank you