Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Nginx for Human-Friendly URL (Confluence)

Grigory Salnikov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 08, 2018

Hello, Community!

Having spent a couple of days trying to get NGINX and Confluence work together as expected I decided to share my experience with you. 

We want to use our Confluence as a public website so we have some SEO considerations such as human-friendly URLs. Yes, I know that there is guidance for making clear URLs without "?pageId"-thing but, unfortunately, this is not our case as we don't use English for our website.

In the config example below there's also a "proxy_pass" section. We use NGINX also as a reverse proxy to change the default port 8090 to standard 80 (as described here)

So, here we go:

server {
location / {
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;
root /opt/atl/instd/atlassian-confluence-6.8.2/confluence/;
location /pages {
if ($args ~ pageId=xxxxxx) {return 301 /your-pretty-url1-goes-here;}
if ($args ~ pageId=yyyyyy) {return 301 /your-pretty-url2-goes-here;}
rewrite ^/your\-pretty\-url1\-goes\-here?$ /pages/viewpage.action?pageId=xxxxxx break;
rewrite ^/your\-pretty\-url2\-goes\-here?$ /pages/viewpage.action?pageId=yyyyyy break;
proxy_pass http://localhost:8090/;
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";

Let me explain what do we have here:


root /opt/atl/instd/atlassian-confluence-6.8.2/confluence/;

changes the root for nginx so that it looks for pages from there. The default "/usr/share/nginx/html/" results in "failed (2: No such file or directory)".


 location /pages {

I choose "/pages" as a nested location, because all of our anonymously accessed pages URLs look something like:


if ($args ~ pageId=xxxxxx) {return 301 /your-pretty-url1-goes-here;}

 redirects the request with the particular pageId to your custom URL

4. And, finally

rewrite ^/your\-pretty\-url1\-goes\-here?$ /pages/viewpage.action?pageId=xxxxxx break;

  rewrites back to the original source page.

The main advantage for us here is that pages diplayed with normal, human-readible URLs all the time whether it's an external link with friendly URL already in place ( or an internal Confluence link. All of them are displayed correctly.

There are also some drawbacks, of course.

The first one is that you have to manually edit the nginx config file for every new page you create. In our case it's not so awful as our website is going to be static.

The second one is that I don't really know how search engines would react to such 301 redirects of ours and wouldn't it be SEO-unfriendly.

So, that all for now. If someone notices any mistakes or has any suggestions, you are most warmly welcome to the discussion :)

Thank you for your attention.

1 comment

Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 09, 2018

Hi Greg! 


I have been asked my users the same questions, unfortunately, we just stop use hard solution. 

But I have used rewritemap directive from httpd. (in the nginx it likes map)


Anyway, if I were you I have do it, external map file:

1. then include it into configuration, which will located on NFS server(then editor can edit map file which mounted on the PC) like this

2. every 1 minute bash script will check  command :

nginx -t 

if it gets config is ok, the run

systemctl reload nginx 


Regarding SEO, I hope this article will help

In my experience, I have used for the SEO trick rewrite rules, if it is not good start user redirect with 301 error.


Hope it helps.




Gonchik Tsymzhitov



Log in or Sign up to comment
AUG Leaders

Atlassian Community Events