OMERO: redirection to https

Hi everyone,

we’ve installed omero 5.5 on RHEL7 using nginx with seperate omero and omero-web servers.
SSL is enabled, so that the omero web server can be reached both by using http and https.
The question is whether it is possible to redirect http requests automatically to https. Basically, if someone enters http://omero-web.example.com he receives https://omero-web.example.com/webclient/login/?url=%2Fwebclient%2F instead.

A simple redirection like
return 307 https://$server_name$request_uri;
or
rewrite ^ https://$server_name$request_uri;
doesn’t seem to work as it breaks the API. Ideas?

There are two ways.

Option one is to use an if statement (this is used on our Dundee production server):

Option two is to define two server blocks, one on port 80 that only redirects to 443, and one on 443 (this is used on some of our production web servers):

server {
    listen       80
      default_server
;

    server_name  $hostname;
    # Redirect all http to https
    return 301 https://$host$request_uri;
}

server {

    listen       443 ssl

    .... omero web proxy

I’ve used option 2 and it works like a charm, thanks!