It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

AJS.contextPath() returns undefined

Zbigniew Skowron Dec 29, 2017

I have Confluence set up behind a reverse proxy.
I redirect https://skowron.it/zbyl to http://localhost/zbyl

What I have done:

  1. I have installed evaluation version of Confluence 6.6.0 on Windows 10 64 bit. I have not installed any plugins.
  2. I've added proxyName="skowron.it" proxyPort="443" scheme="https" in server.xml
  3. I've set <Context path="/zbyl" ...> in server.xml
  4. I've set <property name="confluence.webapp.context.path">/zbyl</property> in confluence.cfg.xml
  5. I have changed Confluence's Base URL to https://skowron.it/zbyl

It mostly works.
However I get this message on each Confluence page I visit:

"Confluence's base URL is set to https://skowron.it/zbyl but you are accessing Confluence from https://skowron.itundefined."

I have managed to debug it to a point, where AJS.contextPath() function returns undefined.

As a result some features of Confluence don't work, because the browser sends requests to bad addresses, such as: "undefined/rest/webResources/1.0/resources" or "undefined/rest/analytics/1.0/publish/bulk".

Oddly enough when I view HTML source of the generated pages. there are 3 places with "context-path", and they all have valid value: "/zbyl".
And yet AJS.contextPath() returns undefined.

For completeness those 3 places are as follows:

<meta id="confluence-context-path" name="confluence-context-path" content="/zbyl">
<meta id="confluence-base-url" name="confluence-base-url" content="https://skowron.it/zbyl">
<meta name="ajs-context-path" content="/zbyl">
<meta name="ajs-base-url" content="https://skowron.it/zbyl">
WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path.context-path"]="\u0022\u005C/zbyl\u0022";

I cannot find any workaround or solution for this problem.
There is however one post with similar symptoms (same broken links) here:
https://community.atlassian.com/t5/Confluence-questions/Collaborative-editing-doesn-t-work-with-NGINX-reverse-proxy/qaq-p/594986

1 answer

0 votes
Ann Worley Atlassian Team Jan 02, 2018

Hi Zbigniew,

It sounds like the context path is set up correctly in Confluence, based on How to change the Confluence context path.

You didn't mention which reverse proxy you are using but the other case you reference is using NGINX so I am going to initially assume that's the proxy you are using.

Since you used proxyPort 443, it sounds like you are terminating SSL at the proxy. Please compare your NGINX configuration to this one, from: Running Confluence behind NGINX with SSL

server {
listen www.example.com:80;
server_name www.example.com;

listen 443 default ssl;
ssl_certificate /usr/local/etc/nginx/ssl/nginx.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/nginx.key;

ssl_session_timeout 5m;

ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location /confluence {
client_max_body_size 100m;
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;
proxy_pass http://localhost:8090/confluence;
}
location /synchrony {
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;
proxy_pass http://localhost:8091/synchrony;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
I look forward to hearing what you find.
Thanks,
Ann
Zbigniew Skowron Jan 02, 2018

Hello,
Thanks for your reply.
It turned out that the reverse proxy was additionally set up to alter "Content-Security-Policy" and "Strict-Transport-Security" HTTP headers.
After removing settings related to that it all works fine.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

1,125 views 7 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you