Nginx子目录中的默认网站路径,而不是/(根目录)
我想配置我的站点,使其在子目录而不是mydomain/中运行。我的意思是,我不想去mysite.com/看这个网站,而是想从mydomain/myproject中看到它。 我正在使用uwsgi与一个flask网站交谈,这是我的/etc/nginx/sites available/myproject配置文件Nginx子目录中的默认网站路径,而不是/(根目录),nginx,webserver,nginx-config,Nginx,Webserver,Nginx Config,我想配置我的站点,使其在子目录而不是mydomain/中运行。我的意思是,我不想去mysite.com/看这个网站,而是想从mydomain/myproject中看到它。 我正在使用uwsgi与一个flask网站交谈,这是我的/etc/nginx/sites available/myproject配置文件 server { server_name mydomain www.mydomain; location / { include uwsgi_params;
server {
server_name mydomain www.mydomain;
location / {
include uwsgi_params;
uwsgi_pass unix:/root/Desktop/myproject/myproject.sock;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.mydomain) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mydomain) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name mydomain www.mydomain;
return 404; # managed by Certbot
}
我试图将代码从location/更改为location/myproject或location=/myproject,但它没有找到我
补充信息
这是我的config.ini文件
我正在使用uwsgi版本2.0.18和nginx/1.14.0 Ubuntu
谢谢试试这个
NGINX配置:
location /mylocation {
include uwsgi_params;
uwsgi_pass unix:/myproject/myproject.sock;
uwsgi_param SCRIPT_NAME /mylocation;
}
uwsgi ini文件:
route-run = fixpathinfo:
编辑:
我尝试在我的nginx配置中重写路径,结果成功了。。在wsgi ini文件中没有特殊配置
location /be {
rewrite /be/(.+) /$1 break;
include uwsgi_params;
uwsgi_pass unix:/myproject/myproject.sock;
}
编辑:所以,我的结论是,当在FlaskApp中使用/root时,uwsgi ini中的fixpathinfo似乎不起作用。如果烧瓶正在使用/,则应设置rewrite/be/*/$1 break;在NGINX配置中
谢谢你!!
什么是fixpathinfo?它仍然没有找到此操作允许您在nginx中设置脚本名称,而无需费心重写路径信息nginx无法提供的功能您是否尝试在ini文件中配置装入点?比如mount=/app1=app1.py?啊哈。。。我想我知道它在哪里。。。我想你在烧瓶应用程序中使用了/root,对吗?因此,更改rewrite/myproject/+/$1 break;重写/myproject//break;
location /be {
rewrite /be/(.+) /$1 break;
include uwsgi_params;
uwsgi_pass unix:/myproject/myproject.sock;
}