2017-09-07 13 views
-3

ec2のビルドサーバーを設定して、nginxとjenkinsを学んでいます。ジェンキンをセットアップするのは簡単で、テストジョブを作成することもできました。私は今それを設定する方法については、nginxの設定と強力な混乱に移動したい。私は自分のドメインでゾーンをホストしており、domain.comと呼ぶことができます。 jenkins.domain.comのAレコードを作成し、値ボックスにec2インスタンスのIPを入力します。ec2のジェンキンのNginx設定

はその後...

の/ etc/nginxの/サイト対応/デフォルト

server { 
    listen 80; 
    server_name jenkins.domain.com; 
    return 301 https://$host$request_uri; 
} 

server { 

    listen 80; 
    server_name jenkins.domain.com; 

    location/{ 

     proxy_set_header  Host $host:$server_port; 
     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 $scheme; 

     # Fix the "It appears that your reverse proxy set up is broken" error. 
     proxy_pass   http://127.0.0.1:8080; 
     proxy_read_timeout 90; 

     proxy_redirect  http://127.0.0.1:8080 https://jenkins.domain.com; 

     # Required for new HTTP-based CLI 
     proxy_http_version 1.1; 
     proxy_request_buffering off; 
     # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651 
     add_header 'X-SSH-Endpoint' 'jenkins.domain.com:50022' always; 
    } 
    } 

私はサイトを取得jenkins.domain.com:80に行くときしかし、到達することができないページにこれを追加しました

+0

あなたはSSLにすべての要求をリダイレクトするために意味しますか? SSLリスナーが設定されていません。 – birryree

+1

証明書を生成しても、問題の一部であるSSLリスナーがまだ設定されていない可能性があります。設定の最初の部分(301リダイレクトを実行する部分)をコメントアウトしてnginxをリロードすると、どうなりますか?同じエラーが出ますか?あなたの 'access.log'と' error.log'ファイルで終わるものは何ですか? – birryree

答えて

1

ここではproxy_redirectは必要ありません。以下のサイト構成を使用することができます。/etc/nginx/site-available(ubuntuの場合)または/etc/nginx/conf.d/(centosまたはrhel)&にファイルジェンキンを作成して、そのファイルの設定をコピーする必要があります。サイト対応のUbuntuでソフトリンクを作成する必要があります。

ln -s /etc/nginx/site-available/jenkins /etc/nginx/site-enabled/jenkins 

ジェンキンスconfファイル

server { 
    listen 80; 
    server_name jenkins.domain.com; 
    access_log /var/log/nginx-access.log; 
    error_log /var/log/nginx-error.log; 
    location/{ 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_redirect off;  
    proxy_read_timeout 150s; 
    proxy_next_upstream error; 
    proxy_pass http://127.0.0.1:8080; 

    # Add HTTP Strict Transport Security for good measure. 
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains;"; 
    } 
}