I have an angular application served by nginx, this angular application is negotiating with the rest of the server on the same server.
I have the following server configuration in my / etc / nginx / sites -available /
"default" and "app" The Angular application runs correctly, by default the server listens for 80.
server{
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ /index.html ;
}
}
Then in my server block "application", which should redirect requests to the backup server,
server{
listen [::]:80 ;
server_name xxx.com;
location / {
proxy_pass http://127.0.0.1:8082;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
angular POST API, 405 ( ), , nginx, ( 8082), OPTIONS , POST , , , CORS REST-.
, , .
, .
EDIT:
MY-
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.9
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
Host:example.com
Origin:http://example.com
Pragma:no-cache
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
My Os
Ubuntu: 16.04,
nginx: 1.10.3.