angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Angular 1.5:fail to connect http://example.com/sockjs-node/info (404) when using nginx as revers proxy

Open clcaza opened this issue 9 years ago • 5 comments

Versions

Angular CLI: 1.5.3
Node: 6.9.5
OS: win32 x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.3
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.3
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1

Repro steps

start webpack dev server: ng serve --aot --hmr -e=hmr --port=8000 --disable-host-check --public-host=http://example.com

nginx config:

server {
        listen       80;
        server_name  example.com;

        location ^~ /sockjs-node {
            proxy_pass         http://localhost:8000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }

        location / {
            proxy_pass         http://localhost:8000;
        }
    }

Observed behavior

Fail to connect http://example.com/sockjs-node/info?t=xxx. The error code is 404.

Desired behavior

connect http://example.com/sockjs-node/info?t=xxx successfully

Mention any other details that might be useful (optional)

Prior to angular 5 and cli 1.5, it works.
When i connect http://localhost:8000/sockjs-node/info without reverse proxy, it works.

clcaza avatar Nov 22 '17 03:11 clcaza

I'm facing this issue as well

RamaneekGill avatar Mar 06 '18 22:03 RamaneekGill

Same problem for me. I have tried to solve it by using

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

But arise another problem,

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:4200/ui/info?t=1522218225977. (Reason: CORS header 'Access-Control-Allow-Origin' does not match '*').

jasimrony avatar Mar 28 '18 06:03 jasimrony

Are you still able to reproduce this issue with the latest version?

mgechev avatar Dec 22 '18 02:12 mgechev

Closing as stale.

filipesilva avatar Oct 08 '19 14:10 filipesilva

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.