Nginx for orthanc

In my machine there is no communication between orthanc and nginx web server. When I shutdown the nginx I can still access to orthanc.
I read almost all documents on the internet about configuration nginx for orthanc. But still it doesn't work.

Can anyone help me this situation?

Please carefully read the FAQ:
http://book.orthanc-server.com/faq/nginx.html

I already read it and applied what it says. But still not working.

As long as you don’t precisely describe your setup and your problem, and you don’t provide your configuration files, nobody will be able to help you.

I made a simple setup for orthanc just type ‘sudo apt-get install orthanc’ and nginx ‘sudo apt-get install nginx’. I’m sharing the configuration files.

11 Ocak 2019 Cuma 09:55:45 UTC+3 tarihinde Sébastien Jodogne yazdı:

orthanc.json (14.6 KB)

nginx.conf (2.24 KB)

It is perfectly normal that you can still access Orthanc on the 8042 port if you are on the localhost or if you haven’t firewalled the 8042 port.

You should test against URL:
http://<IP_OF_SERVER>/orthanc/

And not URL:
http://<IP_OF_SERVER>:8042/

In either case, your question is not related to Orthanc, but to generic network administration.

Thank you Sébastien
Please note that initially the snippet didn’t work, so that it was necessary to change from

`
proxy_pass loclahost:8042;

`

to

proxy_pass http://127.0.0.1:8042;

In

`
location /orthanc/ {
proxy_pass http://127.0.0.1:8042;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
rewrite /orthanc(.) $1 break;
add_header ‘Access-Control-Allow-Credentials’ ‘true’;
add_header ‘Access-Control-Allow-Headers’ ‘DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type’;
add_header ‘Access-Control-Allow-Methods’ ‘GET, POST, OPTIONS’;
add_header ‘Access-Control-Allow-Origin’ '
';
}

`

And included the snippet just after the certificate declaration in my /etc/nginx/sites-enabled/default file, and it worked perfectly.

I would like to share my production nginx config here, it worked for me but maybe there is something unreasonable.
If you find something unreasonable, share your ideas with me, please :slight_smile:

I am using JWT token for authentication, so I proxy token in my SPA cookie to Orthanc request header. Everything works well except some URL formats (still got 403), I list them in another thread.

server {
listen 80;
server_name yourdomain.com;
include conf.d/basic.conf;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl http2;
server_name yourdomain.com;
include conf.d/basic_ssl.conf;
ssl_certificate /root/certs/yourdomain.com/bundle.crt;
ssl_certificate_key /root/certs/yourdomain.com/private.key;
access_log logs/yourdomain.com.log main;
root /root/www/yourdomain.com;
index index.html;

location / {
try_files $uri $uri/ /index.html;
log_not_found off;
}

location /pacs/ {
proxy_pass http://127.0.0.1:8042/;
include conf.d/headers.conf;

if ($request_method = “OPTIONS”) {
add_header Access-Control-Allow-Origin “*”;
add_header Access-Control-Allow-Methods “GET,POST,OPTIONS”;
add_header Access-Control-Allow-Headers “DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Accept”;
add_header Access-Control-Max-Age 1728000;
add_header Content-Type “text/plain; charset=utf-8”;
add_header Content-Length 0;
return 204;
}

add_header Access-Control-Allow-Origin “*”;
add_header Access-Control-Allow-Methods “GET,POST,OPTIONS”;
add_header Access-Control-Allow-Headers “DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Accept”;
add_header Access-Control-Expose-Headers “Content-Length,Content-Range”;

proxy_http_version 1.1;
proxy_redirect off;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_connect_timeout 100;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Authorization “Bearer $cookie_token”;
proxy_cache_bypass $http_upgrade;
rewrite /pacs(.*) $1 break;
}
}

在 2019年7月1日星期一 UTC+8上午3:50:41,Ludwig Moreno写道:

Dear Ludwig,

Thanks for the information! I have modified the FAQ to reflect your insight:
https://book.orthanc-server.com/faq/nginx.html

Sébastien-