hello,
I’m trying to deploy my Django project to an ec2 aws server with nginx.
when I go to my ec2 DNS URL: http://ec2-18-191-234-109.us-east-2.compute.amazonaws.com/
I get the default nginx page.
when I go to my Ip address I do get the site: http://18.191.234.109/ and http://18.191.234.109/order/
I also buy a domain name but it shows the Nginx page and not my Django website: http://www.ms-global.co.il/
where is the problem?
Have you read through the Deploying Django docs? (Even though they talk about using Apache, the parts dealing with running Django through uwsgi or gunicorn still apply.)
If you need more specific help, we’d need to understand more about your deployment environment.
What does your nginx configuration look like? What Python application server are you using? (uwsgi? gunicorn? something else?)
my nginx configuration:
ubuntu@ip-172-31-4-59:/etc/nginx/sites-enabled$ ls
default django.conf
ubuntu@ip-172-31-4-59:/etc/nginx/sites-enabled$ cat django.conf
server{
listen 80;
server_name 18.191.234.109;
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/BeGoodPlus/begoodPlus/app.sock;
}
location /static {
autoindex on;
alias /home/ubuntu/BeGoodPlus/begoodPlus/static;
}
location /media {
autoindex on;
alias /home/ubuntu/BeGoodPlus/begoodPlus/static/media_root;
}
}
ubuntu@ip-172-31-4-59:/etc/nginx/sites-enabled$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
ubuntu@ip-172-31-4-59:/etc/nginx/sites-enabled$
my gunicorn configuration
ubuntu@ip-172-31-4-59:/etc/supervisor/conf.d$ ls
gunicorn.conf
ubuntu@ip-172-31-4-59:/etc/supervisor/conf.d$ cat gunicorn.conf
[program:gunicorn]
directory=/home/ubuntu/BeGoodPlus/begoodPlus
command=/home/ubuntu/env/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/BeGoodPlus/begoodPlus/app.sock begoodPlus.wsgi:application
autostart=true
autorestart=true
stderr_logfile=/var/log/gunicorn/gunicorn.err.log
stdout_logfile=/var/log/gunicorn/gunicorn.out.log
[group:guni]
programs:gunicorn
ubuntu@ip-172-31-4-59:/etc/supervisor/conf.d$ sudo supervisorctl status
guni:gunicorn RUNNING pid 15129, uptime 16:18:20
ubuntu@ip-172-31-4-59:/etc/supervisor/conf.d$
Thank you!, please tell me more information I can provide.
Since It appears you have two active configuration files, we’ll also need to see the default file.
ubuntu@ip-172-31-4-59:/etc/nginx/sites-enabled$ ls
default django.conf
ubuntu@ip-172-31-4-59:/etc/nginx/sites-enabled$ cat default
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
ubuntu@ip-172-31-4-59:/etc/nginx/sites-enabled$
should I just delete this file?
Now it looks like it’s working after I deleted default. Thank you!
Yep, I was going to suggest it. Do you understand why you needed to do that?