2017-05-31 58 views
0

我有3個AngularJS應用程序,每個應用程序都有自己的ExpressJS後端。你如何部署的所有3個應用以這種方式:ExpressJS/NodeJS - 反向代理部署

http://myapp.com/<app1> 
http://myapp.com/<app2> 
http://myapp.com/<app3> 

附加信息:
- 我在部署AWS EC2實例
應用 - 我試圖合併在一個單一的應用程序ExpressJS應用。雖然這個工作,我仍然想知道,如果上述情況是可能的

回答

1
server { 
    listen 80; 
    server_name es.domain.com; 
    location /app1 { 
     rewrite ^/(.*) /$1 break; 
     proxy_ignore_client_abort on; 
     proxy_pass http://localhost:3001; 
     proxy_redirect http://localhost:3001 https://es.domain.com/appw; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Host $http_host; 
     auth_basic "Elasticsearch Authentication"; 
     auth_basic_user_file /etc/elasticsearch/user.pwd; 
} 

    location /app2 { 
     rewrite ^/(.*) /$1 break; 
     proxy_ignore_client_abort on; 
     proxy_pass http://localhost:3002; 
     proxy_redirect http://localhost:3002 https://es.domain.com/app2; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Host $http_host; 
     auth_basic "Elasticsearch Authentication"; 
     auth_basic_user_file /etc/elasticsearch/user.pwd; 
} 
} 

請參考以下鏈接 http://www.minvolai.com/blog/2014/08/Setting-up-a-Secure-Single-Node-Elasticsearch-server-behind-Nginx/Setting-up-a-Secure-Single-Node-Elasticsearch-server-behind-Nginx/

0

你可以設置AWS CloudFront和設置每個應用程序的起源。它提供了從單個域(CloudFront安裝)到不同Express應用程序的靈活性,還允許在Edge位置緩存靜態內容路徑。