Django nginx: [emerg] open () "/ etc / nginx / proxy_params" failed (2: There is no such file or directory) in / etc / nginx / sites -enabled / myproject: 11

I am trying to deploy a django project with Nginx and Gunicorn with this tutorial . I did everything pre-dos, but when I create the file /etc/nginx/sites-available/myprojectwith the code below:

server {
listen 80;
server_name server_domain_or_IP;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /home/sammy/myproject;
}

location / {
    include proxy_params;
    proxy_pass http://unix:/home/sammy/myproject/myproject.sock;
 }
}

and then run sudo nginx -tto search for errors, I get this error:

nginx: [emerg] open() "/etc/nginx/proxy_params" failed (2: No such file or directory) in /etc/nginx/sites-enabled/myproject:11
nginx: configuration file /etc/nginx/nginx.conf test failed

what problem? and how to solve it? Tanx

+4
source share
1 answer

You have the wrong path for proxy_params99% of the time (in my experience), the default location for the file proxy_params /etc/nginx/proxy_params, but for you it doesn’t look like ..

The file proxy_paramscontains the following:

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

, , Centos, proxy_params. , , ,

location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://unix:/home/sammy/myproject/myproject.sock;
 }

, . , :

include /path/to/proxy_params

else ( )

/etc/nginx ( )

+9

Source: https://habr.com/ru/post/1671409/


All Articles