'django ckeditor upload not working in production
django settings:
CKEDITOR_BROWSE_SHOW_DIRS = True
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_RESTRICT_BY_DATE = False
CKEDITOR_UPLOAD_PATH = 'uploads/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_ROOT = os.path.join(BASE_DIR, "attachments")
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'staticfiles'), )
STATIC_URL = f"{FORCE_SCRIPT_NAME}/backend/static/"
MEDIA_URL = f"{FORCE_SCRIPT_NAME}/backend/attachments/"
urls:
urlpatterns = [
path('admin/filebrowser/', site.urls),
path("grappelli/", include("grappelli.urls")),
path('admin/', admin.site.urls),
path("api/", include(api_urlpatterns)),
path('ckeditor/', include('ckeditor_uploader.urls')),
]
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT,
show_indexes=settings.DEBUG)
urlpatterns += static(settings.STATIC_URL,
document_root=settings.STATIC_ROOT,
show_indexes=settings.DEBUG)
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
path("__debug__/", include(debug_toolbar.urls)),
] + urlpatterns
nginx:
location /project_name/ {
set $service project_name;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://$service;
client_max_body_size 16m;
}
In dev all works, upload and browse, but in prod with not (AH00128: File does not exist: /var/www/html/project_name/ckeditor/upload). I try add alias/root to nginx config, change ckeditor path to re_path(r'^ckeditor/', include('ckeditor_uploader.urls')) and still nothing( Not only upload, browse too not working
For example filebrowse works, but not ckeditor. I dont know a reason why.

Solution 1:[1]
Add in projects apache settings in service.conf -> WSGIScriptAliasMatch ckeditor alias:
WSGIScriptAliasMatch ^/${SERVICE}/((admin|api|grappelli|ckeditor)/.*)$ /${SERVICE}/backend/${PROJECT}/wsgi.py/$1
Now works.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Elendiar |


