Project

General

Profile

nginx + ssl

Added by Michael Lednev over 14 years ago

Hello.

I've set up redmine on nginx + ssl but somehow it does not want to use https:// urls for POST requests and redirects to http://

How can fix that behavior?


Replies (8)

RE: nginx + ssl - Added by Felix Schäfer over 14 years ago

See [[RedmineSettings#Protocol].

RE: nginx + ssl - Added by Michael Lednev over 14 years ago

It was set to HTTPS before I asked here. Didn't help.

RE: nginx + ssl - Added by Felix Schäfer over 14 years ago

Do you use passenger or nginx as a reverse proxy?

RE: nginx + ssl - Added by Michael Lednev over 14 years ago

No, I use FCGI. Here's nginx config for redmine:

server {

  listen 8080;

#  ssl on;
#  ssl_protocols SSLv3 TLSv1;
#  ssl_certificate /etc/nginx/ssl/redmine.crt;
#  ssl_certificate_key /etc/nginx/ssl/redmine.key;

  client_max_body_size       100m;
  client_body_buffer_size    128k;

  root /var/www/rails/redmine/public;
  access_log /var/log/nginx/https.log;

  location ~* \.(ico|css|js|html)$ {
    root /var/www/rails/redmine/public/;
  }

  location ~* /images/ {
    root /var/www/rails/redmine/public/;
  }

  location / {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.fcgi;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING     $query_string;
    fastcgi_param  REQUEST_METHOD   $request_method;
    fastcgi_param  CONTENT_TYPE     $content_type;
    fastcgi_param  CONTENT_LENGTH   $content_length;
    fastcgi_param  REQUEST_URI      $request_uri;
    fastcgi_param  SERVER_NAME      $server_name;
    fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;
    fastcgi_param  REQUEST_URI      $request_uri;
    fastcgi_param  DOCUMENT_URI     $document_uri;
    fastcgi_param  DOCUMENT_ROOT    $document_root;
    fastcgi_param  SERVER_PROTOCOL  $server_protocol;
    fastcgi_param  REMOTE_ADDR      $http_forwareded_for;
    fastcgi_param  REMOTE_PORT      $remote_port;
    fastcgi_param  SERVER_ADDR      $server_addr;
    fastcgi_param  SERVER_PORT      $server_port;
    fastcgi_param  SERVER_NAME      $server_name;
  }

}

RE: nginx + ssl - Added by Felix Schäfer over 14 years ago

Mmh, I use neither cgi nor nginx, so I won't be much help. Somehow your rails environment seems not to notice being called on https, but I can't say why, sorry.

RE: nginx + ssl - Added by Igor Isaenko over 14 years ago

I has forced to work it in proxy mode.

And key point was: "proxy_set_header X-Forwarded-Proto https;"

Here config:

root    /opt/redmine/public;
location / {
try_files $uri @fallback;
}
location @fallback {
proxy_pass http://127.0.0.1:3000;
proxy_connect_timeout 15;
proxy_redirect off;
proxy_set_header Host $host;
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 https;
}

RE: nginx + ssl: solution: a bit hackerish, but works - Added by Lauri Korts-Pärn almost 14 years ago

add to nginx.conf

fastcgi_param HTTPS "on";

    (1-8/8)