Reputation: 139
I am trying to deploy my django app on aws ec2 and i created a django.conf file for nginx this is my django.conf file
server{
listen 80;
server_name 15.206.160.34;
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/{project}/app.sock;
}
}
but when i try to run the command sudo nginx -t
i get this error
2025/02/27 10:40:17 [emerg] 15034#15034: directive "proxy_pass" is not terminated by ";" in /etc/nginx/sites-enabled/django.conf:10
nginx: configuration file /etc/nginx/nginx.conf test failed
How do i fix this, please help.
Upvotes: 0
Views: 23
Reputation: 21
You can create a file with sudo nano /etc/nginx/sites-available/myproject
and then type the following into the file:
nginx
server {
listen 80;
server_name yourip;
access_log /var/log/nginx/website-name.log;
location /static/ {
alias /opt/myproject/myproject/path-to-static-files/;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALLDSP COR PSAa PSDa OURNOR ONL UNI COM NAV"';
}
}
Now you need to set up a symbolic link in the /etc/nginx/sites-enabled directory that points to this configuration file. That is how NGINX knows this site is active. Change directories to /etc/nginx/sites-enabled like this:
cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/myproject
and then go to /etc/nginx/nginx.conf
and uncomment # server_names_hash_bucket_size 64;
and finally sudo service nginx restart
.
also dont forget about ufw.
Upvotes: 0