How can I run Orthanc behind nginx?

Similarly to Apache, Orthanc can run behind nginx through reverse proxying. Here is the configuration snippet for nginx:

server {
   listen  80  default_server;
   ...
   location  /orthanc/  {
      proxy_pass http://localhost:8042;
      proxy_set_header HOST $host;
      proxy_set_header X-Real-IP $remote_addr;
      rewrite /orthanc(.*) $1 break;
   }
   ...
}

Note: Thanks to Qaler for submitting this information.

You might also wish to adapt the client_max_body_size configuration option of nginx to allow the uploading of DICOM files larger than the default 1MB if using the REST API of Orthanc.

Enabling CORS

It is also possible to enable cross-origin resource sharing (CORS) with nginx:

server {
   listen  80  default_server;
   ...
   location  /orthanc/  {
      proxy_pass http://localhost: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' '*';
   }
   ...
}

Note: Thanks to Fernando for submitting this information.