title: Executing Liferay behing a Nginx reverse proxy
body: <p>I am trying to test the last version of Liferay (Liferay 7.0-ga4) and install it behind a reverse proxy (nginx). I am using docker and docker compose for testing purposes, and I create a dummy domain <code>docker.domain.com</code>.</p>
  
  <p>Liferay works fine if I access directly to its url and no reverse proxy is configured. </p>
  
  <p>Also, I have success to install Liferay behind the nginx server if I use the root location:</p>
  
  <pre><code>location / {
     proxy_pass http://liferay:8080;
     proxy_set_header X-Forwarded-Server $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-Proto $scheme;
  }
  </code></pre>
  
  <p>Where <code>liferay</code> in the proxy_pass section is the name of the docker container linked in the docker compose. And Liferay's options:</p>
  
  <pre><code>web.server.host=docker.domain.com
  web.server.protocol=http
  web.server.http.port=80
  </code></pre>
  
  <p>To configure the reverse proxy in Liferay. The results is correct if I type <code>http://docker.domain.com/</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/VlxDZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VlxDZ.png" alt="Liferay welcome page"></a></p>
  
  <p>I can login, accept terms and conditions, ... everything seems fine.</p>
  
  <p>But when I use a location that is not root (i.e /lifeay), I have issues with links, images, and css in general. </p>
  
  <p>With a configuraion in nginx similar to:</p>
  
  <pre><code>location /liferay {
     proxy_pass http://liferay:8080;
     proxy_set_header X-Forwarded-Server $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-Proto $scheme;
  }
  </code></pre>
  
  <p>And adding as suggested <a href="https://web.liferay.com/es/community/forums/-/message_boards/message/89225985" rel="nofollow noreferrer">here</a> to Liferay's configuration:</p>
  
  <pre><code>portal.proxy.path=/liferay
  </code></pre>
  
  <p>When accessing to <code>http://docker.domain.com/liferay</code> all url are messed up and CSS are not shown. Here I attach an screenshot of the final result:</p>
  
  <p><a href="https://i.stack.imgur.com/eCsU5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eCsU5.png" alt="Liferay style goes wrong"></a></p>
  
  <p>It is interesting the line</p>
  
  <pre><code>http://docker.domain.com/liferay/liferay
  </code></pre>
  
  <p>Where "liferay" appears two times in the url. Some errors appear at the liferay's tomcat log:</p>
  
  <pre><code>12:48:29,019 WARN  [http-nio-8080-exec-3][code_jsp:172] {code="404", msg="/liferay/o/mentions-web/css/mentions.css", uri=/liferay/o/mentions-web/css/mentions.css}
  12:48:29,021 WARN  [http-nio-8080-exec-8][code_jsp:172] {code="404", msg="/liferay/o/frontend-css-web/main.css", uri=/liferay/o/frontend-css-web/main.css}
   ....
  </code></pre>
  
  <p>Obviously some files are not found. I have created a simple example with docker <a href="https://github.com/jorgehortelano/liferay7-rproxy" rel="nofollow noreferrer">github</a> to test it only spending a few minutes if somebody is interested. Still, I am pretty sure that something is missing in my Liferay configuration, but I am not able to figure out what. At least I am not able to find any clue in the official documentation. </p>