I'm trying to connect my DigitalOcean Droplet to my custom domain. It's a Django website. The server_name will only go to the last thing in the list. So, if I have "server_name www.mydomain.com, mydomain.com" www.mydomain.com won't work (goes to the "Welcome to nginx!" page), but mydomain.com will. If I do the opposite, the opposite happens. What do I do for this? This is basically my "/etc/nginx/sites-available/myproject" as it stands:
server {
listen 80;
server_name xxx.xx.xx.xxx, mydomain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/myproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/root/myproject/myproject.sock;
}
}
The IP doesn't work, but the "mydomain.com" does because it's last. Any idea what might be going on here or how to see? I want to be able to have mydomain.com and www.mydomain.com work.
server_names shouldn't be comma-separated.
Try
server_name 142.93.58.126 mydomain.com;
Related
so I have a ubuntu server that run two different website with two different domain:
www.firstwebsite.com
www.secondwebsite.com
But when I create an AAA record to create a subdomain with the first domain (like this)
demo.firstwebsite.com
If I go to this subdomain it automatically run the application website of my other domain (www.secondwebsite.com)
I tried creating a specific socket&service file for the subdomain for it but it still run the web application of the second domain.
Im not sure what is causing that and how to fix that? thank you
nginx config file
server {
listen 80;
server_name firstwebsite.com;
return 301 $scheme://www.firstwebsite.com$request_uri;
}
server {
listen 80;
server_name www.firstwebsite.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /var/www/firstwebsite;
}
location /media/ {
root /var/www/firstwebsite;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/firstwebsite.sock;
}
}
Whenever I try to go to www.example.com/anything it always redirects to www.example.com.
It works fine if I don't use the domain. Ex: ip.ip.ip.ip/anything works.
here's my sites-available
server {
listen 80;
listen [::]:80;
server_name my_ip_here;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/chris/Portfolio_v2/mysite;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
You need to add your domain name to the server block
server_name www.example.com;
I am using AWS ROUTE 53 to resolve my website domain name. I am able to launch my website with domain name (domain_name.com). However, when I prefix 'www' to the domain name, its opening only the default nginx page
My ROUTE 53 configuration:
MY nginx configuration:
server {
listen 80;
server_name www.schoolnskill.com, schoolnskill.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root <path_to_my_django_project>;
}
location / {
include proxy_params;
proxy_pass http://unix:<path_to>/gunicorn.sock;
#proxy_pass http://unix:<path_to>/gunicorn.sock
}
}
Based on the comments.
Both http://schoolnskill.com/ and http://www.schoolnskill.com/ work now, after fixing the server_name. The issue was caused by comma in:
server_name www.schoolnskill.com, schoolnskill.com;
Removing the comma was the solution:
server_name www.schoolnskill.com schoolnskill.com;
I made Nginx config for My Django project.
For DNS I associate with my IP.
But this config not working, when I'm checking xyz.com in web but getting error ERR_CONNECTION_REFUSED.
server {
listen 80;
server_name xyz.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/project;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/project/project.sock;
}
}
Please correct me if i'm doing wrong.
I am using GoDaddy domain and connectiong it to django+gunicorn+nginx droplet hosted on DigitalOcean.
After all tried configs of DO, nginx, etc., I'm still getting the same result.
When I'm trying to connect via domain, it changes it to IP address and proceeds...
Last nginx config I stopped on is:
server {
listen 80;
server_name example.com www.example.com ip.ip.ip.ip;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/user/webapp;
}
location /media/ {
root /home/user/webapp;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/user/webapp/webapp.sock;
}
}
Removing IP completely from nginx conf results in same behavior but instead of getting Django webpage I'm getting redirected to nginx default webpage and the domain is again changed to IP.
Try using this statement
location \homepage {
rewrite ^ http://$host$request_uri? permanent;
}