Strange Encoding Issues With Nginx
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Problem
With Nginx proxying requests to Confluence, sometimes you will see strange encoding issues around Confluence. Example:
Error when attempting to insert a User List Macro with parameter set to a group with unicode characters:
1
No results were found for groups : test_크드
Errors in
atlassian-confluence.log:
1 2
2016-08-22 16:24:39,134 ERROR [http-nio-8090-exec-281] [atlassian.prettyurls.route.UrlRouterImpl] route Failed to create requestUri /wiki/download/attachments/151291943/%25BF%25F2%25C1%25F7%25C0%CC%B4%C2%B0%25AD%25BE%25C6%25C1%25F6[1].gif due to: Illegal character in path at index 99: /wiki/download/attachments/151291943/%25BF%25F2%25C1%25F7%25C0%CC%B4%C2%B0%25AD%25BE%25C6%25C1%25F6[1].gif -- referer: http://mtest/wiki/display/Ktest/4%29+Stes+SHtes | url:
Diagnosis
Environment
You have Nginx proxying requests to Confluence
Confluence's
conf/server.xml
is properly configured:1 2 3 4 5
<Connector port="8090" connectionTimeout="20000" redirectPort="8443" maxThreads="100" minSpareThreads="10" enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8" protocol="org.apache.coyote.http11.Http11NioProtocol" proxyName="mtest" proxyPort="80"/>
Proper configuration in nginx to proxy the request to Confluence as well:
1 2 3 4 5 6 7 8
location /wiki { proxy_pass http://10.60.2.2:8090/wiki; #proxy_pass http://wiki_servers; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
Bypassing the proxy solves the issue completely
Cause
Double encoding due to the URIEncoding="UTF-8"
in server.xml, and chunked_transfer_encoding
in nginx
Solution
Remove this line in any nginx configuration files:
1
chunked_transfer_encoding on;
Then restart Nginx
Was this helpful?