更改我的域名解析到Nginx服务器上的位置

amrnrhlw  于 2023-03-01  发布在  Nginx
关注(0)|答案(1)|浏览(124)

我有我的免打扰设置为我的域名,我想加载一个Django网站的安装我已经安装。
当我加载www.mywebsite.com时,它加载了一个来自**/var/www/html的mydomain,但我希望它从/home/myname/kkappDashboard**加载;
我使用的是Nginx服务器,下面是站点可用配置

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文件

##
# 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;
}
yb3bgrhw

yb3bgrhw1#

location /static/ {
  root /kkappDashboard;
}

上述位置块将URI //static/*Map到文件/kkappDashboard/static/*
如果您希望提供文件/kkappDashboard/file.txt(不带static/),请考虑尝试:

    • 一米四分一秒**
location ~ ^/static/(.*)$ {
  alias /kkappDashboard/$1;
}
    • 一个月五个月一个月**
location ~ ^/static(/.*)$ {
  root /kkappDashboard;
  try_files $1 =404;
}

相关问题