Strange Encoding Issues With Nginx

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Problem

With Nginx proxying requests to Confluence, sometimes you will see strange encoding issues around Confluence. Example:

  1. Error when attempting to insert a User List Macro with parameter set to a group with unicode characters:

    No results were found for groups : test_크드
  2. Errors in atlassian-confluence.log:

    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: 

            <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:

    	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

Resolution

Remove this line in any nginx configuration files:

chunked_transfer_encoding on;

Then restart Nginx

 

Last modified on Oct 25, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.