2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nginxのX-Forwarded設定

Posted at

背景

nginx -> nginx -> railsのように多段のリバースプロキシーに対応した、nginxのX-Forwarded設定。

nginxのX-Forwarded設定 (location抜粋)

location @proxy {
    proxy_set_header Host $http_host;
    
    # 伝播させていく
    set $ssl off;
	if ($scheme = https) {
        set $ssl on;
	}
	if ($http_x_forwarded_for) {
		set $ssl $http_x_forwarded_for;
	}
	
	set $proto $scheme;
	if ($http_x_forwarded_proto) {
		set $proto $http_x_forwarded_proto;
	}			 
    
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-SSL $ssl;
    proxy_set_header X-Forwarded-Proto $proto;
    
    proxy_set_header X-Sendfile-Type X-Accel-Redirect;
    proxy_pass http://127.0.0.1:3000; 
    proxy_redirect off;		    	       
	internal;
} 
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?