Tracking is not updated when root_path is set
- Dominant language
- Shell
- Stars
- 151
- Forks
- 280
- PR merge metrics
- No merged PRs in 30d
Description
When ckan.root_path is set to /ckan/{{LANG}}, accessing any page, such as the login page, datasets, or organizations, results in requests in the logs being printed with double slashes, as shown in the logs below.
```
2024-10-18` 10:07:09,913 INFO [ckan.config.middleware.flask_app] 200 / render time 0.265 seconds
2024-10-18 10:08:10,418 INFO [ckan.config.middleware.flask_app] 200 / render time 0.287 seconds
2024-10-18 10:08:20,900 INFO [ckan.config.middleware.flask_app] 200 / render time 0.446 seconds
2024-10-18 10:08:20,973 INFO [ckan.config.middleware.flask_app] 200 //webassets/base/757e28ef_main.css render time 0.019 seconds
2024-10-18 10:08:21,071 INFO [ckan.config.middleware.flask_app] 200 //webassets/ckanext-activity/8dd77216_activity.css render time 0.018 seconds
2024-10-18 10:08:21,212 INFO [ckan.config.middleware.flask_app] 200 //webassets/vendor/90dbb6bf_vendor.js render time 0.017 seconds
2024-10-18 10:08:21,215 INFO [ckan.config.middleware.flask_app] 200 //webassets/vendor/6d1ad7e6_bootstrap.js render time 0.016 seconds
2024-10-18 10:08:21,234 INFO [ckan.config.middleware.flask_app] 200 //webassets/vendor/529a0eb7_htmx.js render time 0.016 seconds
2024-10-18 10:08:21,246 INFO [ckan.config.middleware.flask_app] 200 //webassets/base/a65ea3a0_main.js render time 0.014 seconds
2024-10-18 10:08:21,575 INFO [ckan.config.middleware.flask_app] 200 //api/i18n/en render time 0.011 seconds
2024-10-18 10:08:21,606 INFO [ckan.config.middleware.flask_app] 405 Method Not Allowed: The method is not allowed for the requested URL.
2024-10-18 10:08:22,062 INFO [ckan.config.middleware.flask_app] 405 //_tracking render time 0.468 seconds
```
Nginx conf is below:
```
location /ckan {
proxy_pass http://ckan:5000/;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
#proxy_cache cache;
proxy_cache_bypass $cookie_auth_tkt;
proxy_no_cache $cookie_auth_tkt;
proxy_cache_valid 30m;
proxy_cache_key $host$scheme$proxy_host$request_uri;
}
```
I want to discuss whether this is a CKAN issue or if any changes are required in the Nginx configuration.
The tracking functionality is not working with ckan.root_path. The reason is that the request is being forwarded with //_tracking, which does not satisfy the condition in the code from this file: [middleware.py](https://github.com/ckan/ckan/blob/master/ckanext/tracking/middleware.py).
if path == '/_tracking' and method == 'POST':
Please let me know if I am missing any configuration.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing with ckan.root_path=/ckan/{{LANG}} and inspect the Nginx location/proxy_pass configuration alongside ckanext/tracking/middleware.py. Confirm whether the forwarded path becomes //_tracking and whether the request reaches the POST condition. Done means identifying whether the fix belongs in Nginx or CKAN and restoring tracking under root_path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nginx
- Domain
- backend, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100