2017-05-31 55 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位置缓存静态内容路径。