There is an Angular application in the dockerized Nginx. The Nginx configured for https mode with a trusted SSL certificate.
The Nginx config looks like:
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format trace '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server {
server_name www.example.com;
ssl_certificate /etc/ssl/example.crt;
ssl_certificate_key /etc/ssl/example.key;
listen *:80;
listen *:443 ssl spdy;
listen [::]:80 ipv6only=on;
listen [::]:443 ssl spdy ipv6only=on;
return 301 https://example.com$request_uri;
}
server {
server_name example.com;
listen *:80;
listen [::]:80;
return 301 https://example.com$request_uri;
}
server {
server_name example.com;
listen *:443 ssl spdy;
listen [::]:443 ssl spdy;
ssl_certificate /etc/ssl/example.crt;
ssl_certificate_key /etc/ssl/example.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
keepalive_timeout 70;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
}
When the Angular app sends a rest request to the backend, like POST https://user-service/api/update/testuser, I see in the dev tools next request URL: POST https://example.com/user-service/api/update/testuser and get the 405 HTTP code in the response.
Such an issue isn't observed when the Nginx configured for only HTTP mode and the request URL in the dev tools is the same as defined in the Angular app e.g. POST http://user-service/api/update/testuser.
Perhaps this behavior somehow related to security policy, but I didn't find any settings and explanations in the Nginx documentation.
Additional information:
There are several dockerized services in one internal docker network among which the already mentioned Nginx with the Angular app. And only for the Nginx, there is opened port (port mapping). All other services are should be closed from the outside world, therefore, options for proxying requests are not considered.