I've came across a lot of topic, but I can't find the issue of my problem.
I've an app working on : http://example.com:8081/app/
I've an angular app on : http://example.com:8081/app/angular/ and an rest api on http://example.com:8081/app/rest/
I've made an nginx server in order to proxy this domains like :
http://angular.example.com => proxy the angular app and http://rest.example.com => proxy the rest api.
Booth are working, and communicating but I've a problem to store the cookie sent by rest.exemple.com
There is the response header after an login service:
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin: "http://angular.example.com"
Connection:keep-alive
Content-Type:application/json
Date:Tue, 20 Jan 2015 17:52:19 GMT
Server:nginx/1.2.1
Set-Cookie:JSESSIONID=0F69455E4475CDFBF7D1C01BC4C1D121; Path=/app/; HttpOnly
Transfer-Encoding:chunked
Vary:Origin
Then angular don't use this JSESSIONID to make anothers calls...
I've set $httpProvider.defaults.withCredentials = true;, doesn't change anything...
Any idea ?
EDIT : working when I put as url : http://example.com:8080/app/rest/ but not with http://rest.example.com/
There is my nginx conf:
server {
    listen 80;
    server_name rest.example.com;
    location / {
        proxy_pass  http://localhost:8081/app/rest/;
        proxy_redirect off;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}
@sergiocruz : document.cookie return nothing and also with http://example.com:8080/app/rest/
EDIT2 : Working with apache with this post : How to properly set JSESSIONID cookie path behind reverse proxy
If someone have to solution with nginx :)