I wanna make nginx.conf that: - on post proxy_pass on different port - on get returns static files with index.html (serves SPA)
How do I make that, currently I have:
nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
error_log /var/log/nginx/error.log debug;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream nodejs {
server 127.0.0.1:3001;
}
server {
listen 3000;
charset utf-8;
client_max_body_size 5M;
location / {
if ($request_method = POST ) {
proxy_pass http://nodejs;
}
if ($request_method = GET ) {
root /usr/src/app;
try_files $uri /index.html;
}
}
}
}
nginx: [emerg] "try_files" directive is not allowed here in /etc/nginx/nginx.conf:41