Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NG development server - app connecting to localhost:3000/sockjs-node/info when behind reverse proxy #6440

Closed
koen-serneels opened this issue May 24, 2017 · 11 comments
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity1: confusing

Comments

@koen-serneels
Copy link

koen-serneels commented May 24, 2017

Bug Report or Feature Request (mark with an x)

- [X ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.1.0-rc.0
node: 7.7.3
os: linux x64
@angular/cli: 1.1.0-rc.0
@angular/animations: 4.1.3
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/router: 4.1.3
@angular/compiler-cli: 4.1.3
Linux (Ubuntu)

Details

Hi. I'm using the NG development server behind an apache reverse proxy to avoid security domain/cors issues between our front and backend. With rc0 and '--disable-host-check' this all seems to work perfectly. Expect that I see following errors reported in the browser: GET http://localhost:3000/sockjs-node/info?t=1495632403818 net::ERR_CONNECTION_REFUSED

The URL int he browser is not localhost, but that of the reverse proxy:" thttp://proxhost/..." . Might the localhost be due to some absolute path present somewhere in the NG development server? Afaic it does not seem to break anything. I start the server like this: ng serve --host 0.0.0.0 --port 3000 --disable-host-check

@koen-serneels koen-serneels changed the title NG development server - app connecting to localhost:3000/sockjs-node/info when behing reverse proxy NG development server - app connecting to localhost:3000/sockjs-node/info when behind reverse proxy May 24, 2017
@RicardoVaranda
Copy link
Contributor

RicardoVaranda commented May 24, 2017

Hi @koen-serneels ,

You are seeing localhost on your request because you are accessing the website in your browser via http://localhost:3000.

Could you try and access it using your local network address e.g: http://192.168.1.2:3000

@Brocco Brocco added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity1: confusing labels May 25, 2017
@Brocco Brocco self-assigned this May 25, 2017
@bravik
Copy link

bravik commented May 30, 2017

it breaks live reloading..
People change webpack config to fix this, but we cant change webpack config with angular-cli ?
See this.

@koen-serneels
Copy link
Author

@RicardoVaranda Yes I did exactly that accessing it from another machine using the ip address of the RP on which also the dev server is running (RP and dev server run on the same machine). See my post, I was not using localhost

@skesani
Copy link

skesani commented Sep 13, 2017

Hey, any update regarding this issue? I am using the angular-cli so can't change webpack config.

I am also having the same issue.
zone.js:2263 GET https://localhost:4400/sockjs-node/info?t=1505327858161 net::ERR_CONNECTION_REFUSED

@csmithson
Copy link

This problem appears to go away when I remove the port declaration from the URL. What might fix this for everyone is to have the code smart enough to not include the port in the URL if a FQDN is used.

Such as: 127.0.0.1 would include :4200 and dev.mywebsite.com would not.

@JoshDSommer
Copy link

I'm having the opposite problem of this now. instead of listening to locahost:4200 which did work with our reverse proxy setting, in older version of the cli. Now in 1.5.0 it seems to build the sockjs-node server url, from the url in the browser. Which breaks because we have everything running in a folder. I've tried numerous setting an no matter what I do I cannot force the url it listens to to anything other than http://our.localurl/sockjs-node/info?=XXXXXXXX when I need it to either listen to http://localhost:4200/sockjs-node/info?=XXXXXXXX or http://our.localurl/Folder/sockjs-node/info?=XXXXXXXX

@JoshDSommer
Copy link

Update I found I could set this setting with the flag --public-host. which changes sockjs to use the url http://localhost:4200/sockjs-node/info?=XXXXXXXX. I'm also using the flag --disable-host-check although I think I may not actually need it in the future. for anyone else have the same problem this is what my start script looks like now.

ng server --aot --public-host=\"http://localhost:4200\" --disable-host-check

@skesani
Copy link

skesani commented Nov 6, 2017

If anyone still having this problem, when you deploy your code to production environment, set

--live-reload false

So that it will not reload in the production environment, this is not recommended for local since your changes don't reload automatically in local, but highly recommended for production environment.

@hansl hansl unassigned Brocco Feb 6, 2018
@SimonHawesome
Copy link

SimonHawesome commented Mar 27, 2018

@TheOriginalJosh Setting the public host flag worked for me!

Didn't need to disable host check and had to removed the back slashes from the url.

ng serve --public-host=http://localhost:4200

@JoshDSommer
Copy link

@SimonHawesome nice! I had the backslashes in there since it was part of the package.json scripts. glad this worked for you.

@mgechev mgechev closed this as completed Dec 18, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity1: confusing
Projects
None yet
Development

No branches or pull requests

9 participants