我习惯于在本地运行一个小型节点服务器并对远程REST API进行服务调用的开发环境。我现在所处的环境中,所有内容都是本地的。有一个运行REST API的本地tomcat实例,nginx用于将来自我的angular应用程序的调用路由到tomcat服务器。我遇到的问题是运行我的grunt服务器任务-它启动了一个运行在9000端口上的连接服务器;Live reload功能不可用,因为nginx正在侦听端口80,所以要查看更改,我必须访问localhost/xyz。将nginx.server.listen端口更改为端口9000也不起作用。
#user nobody;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
root /Users/me/dev/angular-project/app; //this looks at my angular app
index index.html index.htm;
server_name localhost;
location / {
try_files $uri /index.html?v=100515130;
}
location /services1 {
proxy_pass http://localhost:8080/services1; //this is one of my services call addresses
proxy_set_header Host localhost;
}
location /services2 {
proxy_pass http://localhost:8080/services2; //this is another service call address
proxy_set_header Host localhost;
}
}
include servers/*;}
我希望能够做的是非常标准的事情--查看我的.scss和es6文件并在更改时编译,然后在更改后热重新加载浏览器。下面是我的gruntfile中的连接过程:
connect: {
options: {
port: 9001,
// Change this to '0.0.0.0' to access the server from outside.
//hostname: 'localhost'
hostname: '0.0.0.0'
},
livereload: {
options: {
middleware: function (connect) {
return [
modRewrite([
'^[^\\.]*$ /index.html [L]'
]),
lrSnippet,
mountFolder(connect, '.tmp'),
mountFolder(connect, yeomanConfig.app)
];
}
}
},我不熟悉nginx和tomcat,但对节点构建工具相当熟悉;吞吞吐吐,但这是我继承的¯\_(ツ)_/‘
我需要在我的nginx设置中改变一些东西来实现这一点吗,或者在我的grunt设置中,或者两者都需要改变?
发布于 2016-03-10 15:37:56
connect: {
options: {
port: 9001,
// Change this to '0.0.0.0' to access the server from outside.
//hostname: 'localhost'
hostname: '0.0.0.0'
livereload: 35729
},
livereload: {
options: {
livereload: true
middleware: function (connect) {
return [
modRewrite([
'^[^\\.]*$ /index.html [L]'
]),
lrSnippet,
mountFolder(connect, '.tmp'),
mountFolder(connect, yeomanConfig.app)
];
}
}
},https://stackoverflow.com/questions/35134492
复制相似问题