4

I am used to a development environment where I run a little node server locally and make my service calls to a remote REST API. I'm now in a setup where everything is local. There's a local tomcat instance running the REST API and nginx is being used to route calls from my angular app to the tomcat server. The problem I'm having is running my grunt server task - it starts up a connect server that runs on port 9000; Live reload functionality is unavailable because nginx is listening on port 80, so to see changes I have to got to localhost/xyz. Changing the nginx.server.listen port to port 9000 does not work either.

#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/*;

}

What I'd like to be able to do is pretty standard stuff really - watch my .scss and es6 files and compile on change, then hot reload the browser when changes are made. Here is the connect process in my 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)
        ];
      }
    }
  },

I'm unfamiliar with nginx and tomcat, but pretty comfortable in node build tools; gulp more than grunt but this is what I have inherited ¯\_(ツ)_/¯

Do I need to change something in my nginx setup to make this happen, or in my grunt setup, or both?

rakitin
  • 1,943
  • 6
  • 25
  • 51
  • What is the problem exactly? You don't see hot deployed changes that are made in Tomcat? – dreamwagon Mar 09 '16 at 20:42
  • The problem is the connect server hosts my site locally at localhost:9000. Api calls between my frontend code and the java application providing the services are not routed by nginx because nginx is listening on port 80. I expected everything to work when I set the server.listen property to 9000 in my nginx.conf, but it didn't and I'm not sure why. – rakitin Mar 09 '16 at 20:54

1 Answers1

0

I don't see the options.livereload

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)
        ];
      }
    }
  },
Adi Prasetyo
  • 1,006
  • 1
  • 15
  • 41
Valeriy Solovyov
  • 5,384
  • 3
  • 27
  • 45
  • that should default to true. anyway - it will live reload as long as my browser is pointed to port 9000. the problem is that I cannot make api calls to my Java app in Tomcat when the browser is pointed at port 9000 because nginx only listens for requests on port 80. As stated above, changing that nginx config to 9000 does not work – rakitin Mar 12 '16 at 02:49