title: Accessing WSO2-APIM using Nginx
body: <p>I am accessing my wso2 apim,store and publisher using Nginx.
  and want to access using the following:</p>
  
  <ol>
  <li><p>wso2 api manager to be accessed using nginx url as:
    <a href="https://nginx-ip/wso2am/carbon" rel="nofollow noreferrer">https://nginx-ip/wso2am/carbon</a></p></li>
  <li><p>wso2 store to be accessed using nginx url as:
        <a href="https://nginx-ip/wso2am/store" rel="nofollow noreferrer">https://nginx-ip/wso2am/store</a></p></li>
  <li><p>wso2 store to be accessed using nginx url as:
  <a href="https://nginx-ip/wso2am/publisher" rel="nofollow noreferrer">https://nginx-ip/wso2am/publisher</a></p></li>
  </ol>
  
  <p>I tried using nested location block inside location block but wasn't successful.
  So, now I am working by having a location block for all of them separately but the same also doesn't works.</p>
  
  <p>Here is my nginx configuration file for store:</p>
  
  <pre><code>location /wso2am/store/ 
     {
       proxy_set_header   Host                $host;
       proxy_set_header   X-Real-IP           $remote_addr;
       proxy_set_header   X-Forwarded-Host    $host;
       proxy_set_header   X-Forwarded-For     $proxy_add_x_forwarded_for;
  
       proxy_pass https://wso2-ip:9443/store/;
  
       proxy_redirect https://$http_host/store/ /wso2am/store/;
  
       proxy_cookie_path / /wso2am/;
  
       limit_rate 25M;
       #limit_req zone=wso2am burst=100 nodelay;
     }
  </code></pre>
  
  <p>For the above configuration the GUI for store doesn't appears properly.</p>
  
  <p><a href="https://i.stack.imgur.com/Ou2wa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ou2wa.png" alt="enter image description here"></a></p>
  
  <p>Similarly for publisher and carbon(for apim management console).
  And the nested nginx configuration is as follows:</p>
  
  <pre><code>   location /wso2am/ {
           location /wso2am/store/
              {
              proxy_set_header   Host                $host;
              proxy_set_header   X-Real-IP           $remote_addr;
              proxy_set_header   X-Forwarded-Host    $host;
              proxy_set_header   X-Forwarded-For     $proxy_add_x_forwarded_for;
  
              proxy_pass https://wso2-ip:9443/store/;
  
              proxy_redirect https://$http_host/oauth2/callback /oauth2/callback;
              proxy_redirect https://$http_host/ /wso2am/store/;
              proxy_redirect https://$http_host/wso2am/ /wso2am/store/;
  
  
              proxy_redirect https://$http_host/store/ /wso2am/store/;
  
              proxy_cookie_path / /wso2am/;
  
              limit_rate 25M;
  
           }
     }
  </code></pre>
  
  <p>Where do I have to change in headers or any other location to go correct?</p>
  
  <hr>
  
  <p><strong>Update 1:</strong></p>
  
  <p>My wso2am store and publisher are working after incorporating the comments and using the following nginx conf:</p>
  
  <pre><code>   location /wso2am/ {
  
              proxy_set_header   Host                $host;
              proxy_set_header   X-Real-IP           $remote_addr;
              proxy_set_header   X-Forwarded-Host    $host;
              proxy_set_header   X-Forwarded-For     $proxy_add_x_forwarded_for;
  
              proxy_pass https://wso2-apim-ip:9443/;
              proxy_redirect https://$http_host/carbon/ /wso2am/carbon/;
              proxy_redirect https://$http_host/store/ /wso2am/store/;
              proxy_redirect https://$http_host/publisher/ /wso2am/publisher/;
  
  
              proxy_cookie_path / /wso2am/;
  
             }
  </code></pre>
  
  <p>Note: But using the above configuration,I login to apim-carbon,I get logged in and then if I click on any of the options on the home page such as list,add.I get logged out and the reason behind it after investigation was the CSRF token is not being sent in the request while accessing it using Nginx.</p>
  
  <p>How can the csrfprevention.js issue be resolved keeping it true.?  </p>