I have development situation where i have a domain with multiple services:
https://somewebpage.com
On this service there are multiple project as subdirectories
https://somewebpage.com
<- landing page
https://somewebpage.com/api
<- rest api server
https://somewebpage.com/app
<- my app
So is it possible (and how) to setup nginx and hosts file to reverse proxy only https://somewebpage.com/app
to my local build http://localhost:3000
?
The issue is that when app is deployed is has no issues accessing /api
rest server but when serving locally my nginx reverse proxy intercepts landing page
and rest api server
urls as well.
My nginx configuration looks like:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
index index.html;
proxy_max_temp_file_size 0;
proxy_buffering off;
server {
listen 80;
server_name somewebpage.com;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name somewebpage.com;
ssl_certificate /etc/ssl/certs/certificate.crt;
ssl_certificate_key /etc/ssl/certs/ccertificate.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location /app {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_pass http://localhost:3000;
}
}
}
And in my /etc/hosts
i have:
127.0.0.1 somewebpage.com
Are there any other tricks on how to achieve similar result?
The reason why i try to do this is that if i do it from my localhost:3000
it will respond with CORS
errors and reject my calls to /api
.
Or is this too much of security hazard and i have to ask for other way of access to /api
?
Thanks for your answers in advance.