Invalid Host header error in browser when accessing OHIF

51 views
Skip to first unread message

Yogesh Devi

unread,
Feb 21, 2023, 11:58:37 AM2/21/23
to cornerstone platform
Hello 
I downloded the latest sources of OHIF viewer ( from https://github.com/OHIF/Viewers.git) and built it using following commands 

 export NODE_OPTIONS=--openssl-legacy-provider
yarn install
yarn config set workspaces-experimental true



Then I tried running it either the test config as 

yarn run dev 


Or I try running it using following command 

APP_CONFIG=config/e2e.js yarn start

Both ways - it runs fine I get a message that denotes the server is running fine and listening on port 3000  (see below) 

....
@ohif/viewer: <i> [webpack-dev-server] Project is running at:
@ohif/viewer: <i> [webpack-dev-server] Loopback: http://localhost:3000/
@ohif/viewer: <i> [webpack-dev-server] On Your Network (IPv4): http://x0.x0.0.x0:3000/
@ohif/viewer: <i> [webpack-dev-server] On Your Network (IPv6): http://[fe80::2e0:4cff:fe68:3d6]:3000/
@ohif/viewer: <i> [webpack-dev-server] Content not from webpack is served from '/home/ydevi/dicomweb, ../../testdata' directory
@ohif/viewer: <i> [webpack-dev-server] 404s will fallback to '/index.html'

However after this when I try to access the viewer by pointing a browser from another server  to http://<my ip>:3000/Viewer

I see a "Invalid Host header" message on my remote  browser .

How do I change the web  config in order to allow remote clients accessing the viewer ?

Or do I have to build it differently ?

Thanks for your  help

Best regards 

Yogesh 

Juan Pablo Bizantino

unread,
Feb 21, 2023, 7:23:51 PM2/21/23
to Yogesh Devi, cornerstone platform
Hello Yogesh,

Per your comment I assume that OHIF is working fine in your local computer but you have problems accessing from an external device.

Did you check your computer firewall?

Juan 



--
You received this message because you are subscribed to the Google Groups "cornerstone platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cornerstone-plat...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cornerstone-platform/4b7df3f9-7473-460b-a538-bb532f2da8f1n%40googlegroups.com.
Message has been deleted

Yogesh Devi

unread,
Feb 22, 2023, 2:35:12 AM2/22/23
to cornerstone platform
Hello Juan Pablo
Thanks for your response

It is certainly  not a firewall issue  - because the browser does receive an http response from server 
The response from server  indicates that server rejects non-local connections.
Moreover on the server side ( where the OHIF viewer is running I see that browser connection does reach and is established on port 3000 

tcp6       0      0 :::3000                 :::*                    LISTEN
tcp6       0      0  x.x.x.x   :3000            y.y.y.y   :64971     ESTABLISHED
tcp6       0      0  x.x.x.x   :3000           y.y.y.y   :64972     ESTABLISHED


So it seems like its a (default) setting in OHIF viewer’s built in webserver that rejects non-local connections.

Can someone point me to webserver configuration for OHIF please 

Yogesh

 


Juan Pablo Bizantino

unread,
Feb 22, 2023, 7:09:09 AM2/22/23
to Yogesh Devi, cornerstone platform
Hello Yogesh,

Current version (4.12.50) is working. 

@ohif/viewer: <i> [webpack-dev-server] Loopback: http://localhost:3000/
@ohif/viewer: <i> [webpack-dev-server] On Your Network (IPv4): http://192.168.1.14:3000/
@ohif/viewer: <i> [webpack-dev-server] On Your Network (IPv6): http://[fe80::867c:f14d:671e:4862]:3000/
@ohif/viewer: <i> [webpack-dev-server] Content not from webpack is served from '/home/juan/dicomweb, ../../testdata' directory

@ohif/viewer: <i> [webpack-dev-server] 404s will fallback to '/index.html'

I have downloaded the code on my Ubuntu laptop and ran the following commands

    • yarn install
    • yarn config set workspaces-experimental true
    • yarn start

    Then I got an error (Error: error:0308010C:digital envelope routines::unsupported) and found the solution on https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported

    • export NODE_OPTIONS=--openssl-legacy-provider

    My software versions are:
    • Node version is 18.9.1
    • Yarn 1.22.19

    I was able to open the project on my local computer and on my mobile phone pointing to my notebook ip.

    Study list is located on http://localhost:3000/    (without /viewer)



    Regards,


    Juan













    Yogesh Devi

    unread,
    Feb 22, 2023, 8:09:57 AM2/22/23
    to cornerstone platform
    Hello Juan
    Those are exactly the steps that I followed and I get it running like you did 
    To understand my problem please try to access the viewer from another server on your network ( not from localhost ) pointing at your IP address 
    I suppose your IP address is   192.168.1.14 so please access it as    http://192.168.1.14:3000/viewer 

    When I try that - I get an error on the browser from which I access this -  that says "Invalid Host header" 

    So I read through https://v3-docs.ohif.org/deployment/ and I gather that The OHIF Viewer can be embedded in other web applications via it's packaged script source, or served up as a stand-alone PWA (progressive web application

    I suppose presently I am using it as a  stand-alone PWA (progressive web application

    When OHIF is used as  stand-alone PWA (progressive web application)  - is it designed to be accessed from a browser client running on  host OTHER THAN localhost ? Snice the web server is returning an http header that denotes "invalid host" is there a setting that I need to change 

    Or alternatively would you rather that I build OFIF so I deploy it on a third part web server like nginx and in that case should I follow a different way to build ?

    Thanks again for your help 

    Yogesh Devi

    unread,
    Feb 22, 2023, 8:59:04 AM2/22/23
    to cornerstone platform
    Hello 
    Or let me phrase my question a bit differently if that helps 
    I guess that the ohif viewer uses the yarn "http-server" or the "node-http-server" package ..
    and in that case I'd need to determine the config that will allow me to have http server accept requests to the external facing ip address / domain name 

    Like if it were using "node-http-server" then i need a way that is akin to specifying 0.0.0.0 for domain 

    Hope this clarifies 

    If it instead confuses the matter then ignore this comment for now 

    Juan Pablo Bizantino

    unread,
    Feb 22, 2023, 10:01:55 AM2/22/23
    to Yogesh Devi, cornerstone platform
    Here is a pic from my Android phone pointing to http://192.168.1.14:3000

    image.png

    Same test using my Ubuntu computer but accessing through the public ip.

    image.png



    Seems to be your error.

    Regards

    Juan Pablp




    Yogesh Devi

    unread,
    Feb 22, 2023, 1:17:15 PM2/22/23
    to Juan Pablo Bizantino, cornerstone platform

    Thanks Juan

    Finally I isolated my issue with the fact that I was using a domain name to access the OHIF server – once I switched to using IP address that issue went away

    It is another story that I am now stuck with module dependency error  - however that deserves an independent conversation

    Thanks a lot for all your help so far

     

    Kind regards

     

    From: cornerston...@googlegroups.com <cornerston...@googlegroups.com> On Behalf Of Juan Pablo Bizantino
    Sent: Wednesday, February 22, 2023 8:31 PM
    To: Yogesh Devi <yoges...@InsiteOne.com>
    Cc: cornerstone platform <cornerston...@googlegroups.com>
    Subject: Re: Invalid Host header error in browser when accessing OHIF

     

    You don't often get email from jpbiz...@gmail.com. Learn why this is important

    Here is a pic from my Android phone pointing to http://192.168.1.14:3000

     

     

    Same test using my Ubuntu computer but accessing through the public ip.

     

    --
    You received this message because you are subscribed to a topic in the Google Groups "cornerstone platform" group.
    To unsubscribe from this topic, visit https://groups.google.com/d/topic/cornerstone-platform/yTe7Fdg5vY4/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to cornerstone-plat...@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/cornerstone-platform/CAGavnknWJSJrYBtYRK2H4u7-Ed-t7_o0OG-2HaRzt877Yo3hvQ%40mail.gmail.com.

    Juan Pablo Bizantino

    unread,
    Feb 22, 2023, 1:32:38 PM2/22/23
    to Yogesh Devi, cornerstone platform
    Glad to help! Greetings from Argentina.
    Reply all
    Reply to author
    Forward
    0 new messages