我不理解这种行为来自于在gunicorn上运行的django,它使用nginx的静态文件托管和端口转发。你知道吗
项目目录树:
.
├── myproj
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── pages
│ ├── __init__.py
│ ├── apps.py
│ ├── static
│ │ └── pages
│ │ └── index.css
│ ├── templates
│ │ └── pages
│ │ └── index.html
│ ├── urls.py
│ └── views.py
页码/网址.py地址:
urlpatterns = [
path('', views.index, name='home'),
path('static-home/', views.index, name='static-home'),
]
我的项目/网址.py地址:
urlpatterns = [
path('admin/', admin.site.urls),
path('pages/', include('pages.urls')),
path('', include('pages.urls')),
]
如果I python manage.py runserver
,那么在这些uri上一切都按预期工作
http://127.0.0.1:8000/
http://127.0.0.1:8000/static-home/
http://127.0.0.1:8000/pages/
http://127.0.0.1:8000/pages/static-home/
如果我用gunicorn+nginx做dockerize (如本文所述:https://blog.skindc.co.uk/dockerise-django-and-static-files-with-nginx/)
然后我看到了不同的行为
good: http://<docker-machine-ip>/
nginx 404: http://<docker-machine-ip>/static-home/
good: http://<docker-machine-ip>/pages/
good: http://<docker-machine-ip>/pages/static-home/
我会添加任何其他信息,如果要求,但为了保持我的docker文件,docker compose,简洁的立场,nginx.conf文件,等等,与上面链接的教程中显示的相同。你知道吗
为什么我可以从<docker-machine-ip>/pages/
的页面添加所有URL,但我只能从<docker-machine-ip>/
的页面添加主页而不能添加其他内容?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐