我想在amazon ec2实例上运行node.js应用。这就是我所做的。
npm install -g yo
npm install -g generator-angular
yo angular
grunt serve
这是Gruntfile.js的片段
// The actual grunt server settings
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: '0.0.0.0',
livereload: 35729
},
livereload: {
options: {
open: true,
base: [
'.tmp',
'<%= yeoman.app %>'
]
}
},
test: {
options: {
port: 9001,
base: [
'.tmp',
'test',
'<%= yeoman.app %>'
]
}
},
dist: {
options: {
base: '<%= yeoman.dist %>'
}
}
}
当我从端口80的Web浏览器访问我的ec2实例时,我希望看到示例角度页面。
我该怎么做才能做到这一点?
答案 0 :(得分:0)
为此,您可以使用代理,例如nginx
sudo yum install nginx
然后你只需更新/etc/nginx/nginx.conf的位置部分来代理你的端口9000:
<snip>
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:9000/;
}
</snip>
重启nginx服务:
sudo service nginx restart
那应该这样做。