2

I've been trying to add a NodeJS app (built by Yeoman - angular-fullstack generator) on my apache server. I've found this other answered question : Apache and Node.js on the Same Server suggesting to use ProxyPass like this :

ProxyPass /node http://localhost:8000/

The problem I encounter when I do that is that my app starts on an index.html wich includes some files with href. Since these hrefs doesn't start like this

href="/node/..."

They aren't redirected by Proxypass, and thus result in a 404 error.

I can't just change all the hrefs : that would mean I need to do it all over again on my 3 environment : development, production and test, and even if I did that, everytime I'll use Grunt to test my app, it automatically rebuild my index.html anyway. (Besides, it doesn't solve everything, there are some problems with socketio appearing when I do that)

Only thing I can do then is using ProxyPass like this :

ProxyPass / http://localhost:8000/

There it does works, absolutely no problem, just like if I actually was using the app on from my server on localhost.

The only remaining problem is that I need to have 2 environments on my server, on for production and on for tests, and I just can't do

ProxyPass / http://localhost:8000/
ProxyPass / http://localhost:8001/

It obviously won't work since everything will be redirected to port 8000 bvefore anything can reach the second line.

So, I'm left with only two options :

Either find another solution than using "/" as criterion for redirecting to localhost:8000 that would work in the same manner (and I didn't find anything working)

Or use virtual hosts... And there goes another problem : I'm really not confortable with network issues, from what I understood, to have several virtual hosts on the same machine, I need several CNAMES (one for each virtual hosts), but I don't know how to list / add CNAMES (my server runs on Windows Server 2008 with no access to the world wide web), and I don't have any "DNS" application in my "Administrative Tools" as I'm supposed to according to this : https://technet.microsoft.com/en-gb/library/cc753579.aspx

Any help would be very welcome Thanks in advance !

EDIT : I really think that my solution is to twitch my Apache configuration. Can anyone used to deal with server configs help me? :/

Community
  • 1
  • 1
Dorian Fusco
  • 303
  • 2
  • 8
  • You can try prefixing all your AJAX requests, and then use that prefix in ProxyPass. – Gaurav Apr 21 '15 at 11:47
  • I don't think these are AJAX requests, just some plain HTML href attributes, and since Yeoman overwrite almost anything I do on the index.html, that wouldn't be a long term repair since I would need to redo that everytime I have a new version to put on production / test – Dorian Fusco Apr 21 '15 at 12:04
  • What is the structure for these href ? – Gaurav Apr 21 '15 at 12:28
  • most of them are href="bower_components/..." or href="app/..." But these links will be the same in both prod en test servers, so I can't do it using another ProxyPass for these – Dorian Fusco Apr 21 '15 at 12:36

1 Answers1

1

Seems like all I was missing was a

<base href="/node/">

tag (didn't even know about it, and Yeoman created it as )

I still have a problem though :

Socket.io ... I don't really get my own problem here : it's in node_modules (wich is normal since I need it in my server and my client), but trying to include it as I was doing so before using base href fails. I don't even get how it did work before : (index.html : ) <script src="socket.io-client/socket.io.js"></script> This doesn't seem right knowing my project folder is like this :

[PROJECT ROOT]

-client

--index.html

-node_modules

--socket.io-client

---socket.io.js

Dorian Fusco
  • 303
  • 2
  • 8