https
nginx์์ http
์ https
๋ก ๋ฆฌ๋๋ ์
ํ๊ณ github oauth ์ฑ ์ค์ ์์ URL์ http ๋ฒ์ ์ ์ฝ๋ฐฑ URL๋ก ์ฌ์ฉํฉ๋๋ค.
(# 647 ๊ด๋ จ)
๊ทธ๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ต๋๋ค.
์ฝ๋ฐฑ URL์ ์ค์ ๋ก Zammad๊ฐ ์๋ github์ ์ค์ ๋์ด ์์ต๋๋ค.
์ฌ๊ธฐ:
๊ฐ์ฌํฉ๋๋ค @ madd86 !
@ madd86 ๊ทธ๊ฒ ๋ด๊ฐ ํ ์ผ์ ๋๋ค. ๋ค๋ฅธ ๊ฒ์ ์๋ํ๋๋ก ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋๋ค.
์๋ ํ์ธ์ @schurig -ups. ๋ฒํผ์ ๋๋ฌ ์ผ์ฐ ๐
๋๋ ํ๋์ ๋ถ์ํ๊ณ ๋น์ ์ด ๊ฒช๊ณ ์๋ ๋ฌธ์ ๋ฅผ ์ฌํ ํ ์ ์์ต๋๋ค. ์ฌํ๊ฒ๋ Zammad ๋ฒ์ (Ominauth์์ ์ํ)๋ฅผ ๋ฒ์ด ๋ฌ์ผ๋ฏ๋ก ์ง์ ์์ ์ ์ ๊ณต ํ ์ ์์ต๋๋ค. ๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ ์ฐ๋ฆฌ๋ ๊ทธ๊ฒ์ ์๋์ํค๊ธฐ์ํ ์ต์์ ์๋ฃจ์ ์ ์ฐพ๊ธฐ ์ํด ๊ทธ๊ฒ์ ๋ ๋ถ์ ํ ๊ฒ์ ๋๋ค.
์ฌ์์ฐ ๋ฐฉ๋ฒ :
ํ์ฌ ์ํ :
redirect_url์ ์ฌ๊ธฐ์์ ๊ฐ์ ธ์ต๋๋ค.
https://github.com/intridea/omniauth-github/blob/master/lib/omniauth/strategies/github.rb#L5
https://github.com/intridea/omniauth-oauth2/blob/master/lib/omniauth/strategies/oauth2.rb#L47
https://github.com/omniauth/omniauth/blob/8098855f6b52f5f1aecbd700e7068f204adddfdd/lib/omniauth/strategy.rb#L435
https://github.com/omniauth/omniauth/blob/8098855f6b52f5f1aecbd700e7068f204adddfdd/lib/omniauth/strategy.rb#L428
https://github.com/omniauth/omniauth/blob/8098855f6b52f5f1aecbd700e7068f204adddfdd/lib/omniauth/strategy.rb#L503
์ด๋ฌํ RACK ENV ์ค ์ผ๋ถ๊ฐ ์ ๋๋ก ์ค์ ๋์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค. NGINX conf๋ฅผ ํตํด ์ํฅ์ ๋ฏธ์น ์ ์๋์ง ๋๋ Rails ์ปจํ ์คํธ์์ ์ด๋ป๊ฒํด์ผํ๋์ง ํ์ธํด์ผํฉ๋๋ค.
์๋ ํ์ธ์ @schurig- ์ ๊ฐ๋ฐ์ ๊ฒ ๊ฐ์์! NGINX ์ค์น๋ก ์คํ ์ค์ ๋๊น? ๊ทธ๋ ๋ค๋ฉด ๊ตฌ์ฑ์ ์ ๋ฐ์ดํธํ๊ณ ๋ค์ ๋ ์ค์ ์ถ๊ฐํ์ญ์์ค.
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
์คํฌ๋ฆฐ ์ท์์์ ๊ฐ์ด :
NGINX์ Zammad๋ฅผ ๋ค์ ์์ํ๊ณ ์๋ ค์ฃผ์ธ์. Apache๋ ๋ค์ ํ์ด์ด์ผํฉ๋๋ค.
RequestHeader set Host zammad.example.com
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
๊ธฐ๋ก์ ์ํด : ์๋ก์ด ๋ ์ผ ์ด๋์
๋ผ์ด์ config/initializers/debug_ssl.rb
์์ Omniauth SSL ๊ฐ์ง๋ฅผ ๋ฎ์ด ์ฐ๋ ์ด๋์
๋ผ์ด์ ๋ฅผ ํตํด rack.envs๋ฅผ ๋คํํ์ต๋๋ค.
Rails.application.config.to_prepare do # to_prepare ensures that the monkey patching happens before the first request
OmniAuth::Strategy.class_eval do # reopen the class
protected
def ssl? # redefine the ssl? method
# DEBUG/CUSTOMIZATION
File.write('/tmp/omniauth.log', request.env.inspect)
# DEBUG/CUSTOMIZATION
request.env['HTTPS'] == 'on' ||
request.env['HTTP_X_FORWARDED_SSL'] == 'on' ||
request.env['HTTP_X_FORWARDED_SCHEME'] == 'https' ||
(request.env['HTTP_X_FORWARDED_PROTO'] && request.env['HTTP_X_FORWARDED_PROTO'].split(',')[0] == 'https') ||
request.env['rack.url_scheme'] == 'https'
end
end
end
๊ทธ๋ฆฌ๊ณ ํ์ธ ๋ ๋ณ์๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.
์ด๊ฒ์ด ๋ฌธ์ ์์ต๋๋ค! ๊ฐ์ฌ!! ๐ โค๏ธ
ํผ๋๋ฐฑ์ ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค! ์ปค๋ฐ์ด ์งํ ์ค์ ๋๋ค. ๐ ๋ค์ ํธ๊น์ง.
์ด ๋ต๋ณ์ ์๋ํด๋ณด์ญ์์ค.
https://stackoverflow.com/a/41466634/1770571
@salmagomaa ์ด๊ฒ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง ์์ผ๋ฉฐ Zammad ๋ด์ ๋ฒ๊ทธ์์ต๋๋ค.
๊ฒ์๋ฌผ์ ์ฌํ์ฉํ์ง ๋ง์ญ์์ค. ๋ฌธ์ ๋ ์ด๋ฏธ ํด๊ฒฐ๋์์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋ ํ์ธ์ @schurig- ์ ๊ฐ๋ฐ์ ๊ฒ ๊ฐ์์! NGINX ์ค์น๋ก ์คํ ์ค์ ๋๊น? ๊ทธ๋ ๋ค๋ฉด ๊ตฌ์ฑ์ ์ ๋ฐ์ดํธํ๊ณ ๋ค์ ๋ ์ค์ ์ถ๊ฐํ์ญ์์ค.
์คํฌ๋ฆฐ ์ท์์์ ๊ฐ์ด :
NGINX์ Zammad๋ฅผ ๋ค์ ์์ํ๊ณ ์๋ ค์ฃผ์ธ์. Apache๋ ๋ค์ ํ์ด์ด์ผํฉ๋๋ค.
๊ธฐ๋ก์ ์ํด : ์๋ก์ด ๋ ์ผ ์ด๋์ ๋ผ์ด์
config/initializers/debug_ssl.rb
์์ Omniauth SSL ๊ฐ์ง๋ฅผ ๋ฎ์ด ์ฐ๋ ์ด๋์ ๋ผ์ด์ ๋ฅผ ํตํด rack.envs๋ฅผ ๋คํํ์ต๋๋ค.๊ทธ๋ฆฌ๊ณ ํ์ธ ๋ ๋ณ์๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.