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;
}
}
Related
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'm trying to connect Django back-end to a React build provided to me by the front-end developer. I'm using Gunicorn for Django and Web server is Nginx.
The below config file is a result of extensive Googling.
Currently Django back-end works on port 80/8000 but whenever I change the port to anything else like 8001 below, the server does not respond.
The complete thing is running on Google Ubuntu VM.
I've executed sudo ufw disable for testing purposes.
server {
#listen 80;
listen 8001;
listen [::]:8001;
server_name xx.xx.7.xx;
location = /favicon.ico {
access_log off;
log_not_found off;
}
location /static/ {
root /home/username/cateringm;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
#location / {
# try_files $uri $uri/cm_react_build/build/index.html; # this is where you serve the React build
# }
}
server {
listen 8002;
listen [::]:8002;
server_name xx.xx.7.xx;
root /home/username/cm_react_build/build;
index index.html index.htm;
location /static/ {
root /home/username/cm_react_build/build;
}
location /test {
root /home/username/cm_react_build/build;
index index.html;
try_files $uri $uri/ /index.html?$args;
}
}
I'm new to configuring web servers. Help would be appreciated.
I found the problem. Google by default blocks all ports except port 80. I updated the firewall rules for different ports and the requests were going through.
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;
}
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;