I have a setup with Nginx and Uwsgi for a Django site. This site is running on a separate ip address for a https certificate.
If someone tries to access the site by ip I get an error message because the ip is not in the allowed host in the Django settings. Of course I can change this, but I would prefer that my site is not accessible by ip. If that is not possible, it would be great if the user gets the default directadmin page from public_html (same behaviour as shared ip).
I use a custom httpd configuration to load the uwsgi/django site. Here is the nginx config:
If someone tries to access the site by ip I get an error message because the ip is not in the allowed host in the Django settings. Of course I can change this, but I would prefer that my site is not accessible by ip. If that is not possible, it would be great if the user gets the default directadmin page from public_html (same behaviour as shared ip).
I use a custom httpd configuration to load the uwsgi/django site. Here is the nginx config:
Code:
server
{
location / {
return 301 https://$host$request_uri;
}
listen 5.9.122.90:80;
server_name mysite.com www.mysite.com ;
access_log /var/log/nginx/domains/mysite.com.log;
access_log /var/log/nginx/domains/mysite.com.bytes bytes;
error_log /var/log/nginx/domains/mysite.com.error.log;
root /home/mysite/domains/mysite.com/public_html;
index index.php index.html index.htm;
include /usr/local/directadmin/data/users/mysite/nginx_php.conf;
include /etc/nginx/webapps.conf;
}
upstream django-mysite {
server unix:///home/mysite/mysite/mysite.sock;
}
server
{
# Django media
location /media {
alias /home/mysite/mysite/media;
}
location /static {
alias /home/mysite/mysite/static;
}
location / {
if ($http_host ~ "^mysite\.com"){ rewrite ^(.*)$ https://www.mysite.com$1 permanent; }
uwsgi_pass django-mysite;
include /home/mysite/mysite/uwsgi_params;
}
listen 5.9.122.90:443 ssl;
server_name mysite.com www.mysite.com ;
access_log /var/log/nginx/domains/mysite.com.log;
access_log /var/log/nginx/domains/mysite.com.bytes bytes;
error_log /var/log/nginx/domains/mysite.com.error.log;
root /home/mysite/domains/mysite.com/private_html;
index index.php index.html index.htm;
ssl on;
ssl_certificate /usr/local/directadmin/data/users/mysite/domains/mysite.com.cert;
ssl_certificate_key /usr/local/directadmin/data/users/mysite/domains/mysite.com.key;
include /usr/local/directadmin/data/users/mysite/nginx_php.conf;
include /etc/nginx/webapps.ssl.conf;
}