I have asked a related question but has solved it already.
Using nginx
provided a reverse proxy.
The config file is taking from project document, I paste it below.
Current situation is:
The backend service is working on port 8080. And the front end is working on port 9001.
$ netstat -anp |grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::8080 :::* LISTEN 26707/java
$ netstat -anp |grep 9001
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:9001 0.0.0.0:* LISTEN 12130/grunt
I can visit the localhost:9001 on machine A where the service is running.
While visits from any other machine in the same LAN. It shows the error page. If go with Inspect
, there is a message in the error page.
Cannot open document for: /eplmp-server-rest/api/auth/providers from http://192.168.1.164:8989/
192.168.1.164
is the machine A's IP address.
/eplmp-server-rest/api/*
should be the endpoint serve by the backend service.
The XHR
Network
Headers
from machine A.
General
Request URL: http://localhost:8080/eplmp-server-rest/api/auth/providers
Request Method: GET
Status Code: 200 OK
Remote Address: [::1]:8080
Referrer Policy: no-referrer-when-downgrade
Requst Headers
Provisional headers are shown
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://localhost:9001
Referer: http://localhost:9001/
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
from another machine in the same LAN
Request URL: http://localhost:8080/eplmp-server-rest/api/auth/providers
Referrer Policy: no-referrer-when-downgrade
Provisional headers are shown
Accept: application/json, text/javascript, /; q=0.01
Origin: http://192.168.1.164:8989
Referer: http://192.168.1.164:8989/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
The related nginx config file.
# Simple http proxy
server {
listen 8989;
server_name localhost;
# Static grunt server
location / {
# Use grunt server (require grunt serve command)
proxy_pass http://localhost:9001;
# OR serve static files directly :
# charset utf-8;
# root /path/to/docdoku-web-front/dist;
# expires 0d;
# access_log off;
}
# Webservices REST
location /api {
proxy_pass http://localhost:8080;
}
# Websocket application
location /ws {
proxy_pass http://localhost:8080/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 7200s;
}
}