Changing the location where my domain resolved to on a Nginx server

I can't figure why it's not working or how to domain is pointing to the incorrect server.

When I load www.mywebsite.com it loads a mydomain but from /var/www/html but I want it to load from /home/myname/kkappDashboard;

I'm using a Nginx server and here is the sites-available configuration
sites-available file:

server {
        listen 80;
        server_name 151.236.222.57 www.mywebsite.com mywebsite.com;
        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/myname/kkappDashboard;
    }
        location / {
            include proxy_params;
            proxy_pass 
http://unix:/home/myname/kkappDashboard/kkappDashboard.sock;
        }
    }
server {
    listen 443 ssl http2;
    server_name www.mywebsite.com;
    # redirect
    return 301 https://mywebsite.com.com$request_uri;
}
server {
    listen 443 ssl http2;
    server_name mywebsite.com;

}

nginx.conf file

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;


server {
    listen 80;
   server_name 151.236.222.xx;
    return 301 $https://www.mywebsite.com$request_uri;
}

1 Reply

The issue may be that the server root is located inside your location block. I suggest moving it out of that block so that it looks more like this example:

server {
    server_name www.example.com;
    root /var/www/nginx-default/;
    location / {
        # [...]
    }
    location /foo {
        # [...]
    }
    location /bar {
        root /some/other/place;
        # [...]
    }
}

If that doesn't resolve the issue, you may want to double check your configurations against what the Linode documentation has. If you're using Nginx as a reverse proxy, you can check out this guide.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct