Skip to content

Instantly share code, notes, and snippets.

@kloudsamurai
Last active December 11, 2020 10:56

Revisions

  1. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -65,7 +65,6 @@ http {
    location @jenkins {
    sendfile off;
    proxy_pass http://127.0.0.1:8080;
    proxy_read_timeout 90;
    proxy_redirect http:// https://;

    proxy_set_header X-Forwarded-Proto $scheme;
  2. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ http {


    ssl_protocols TLSv1;
    ssl_ciphers HIGH: !aNULL:!MD5;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    #this is the jenkins web root directory (mentioned in the /etc/default/jenkins file)
  3. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 9 additions and 8 deletions.
    17 changes: 9 additions & 8 deletions jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ http {


    ssl_protocols TLSv1;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_ciphers HIGH: !aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    #this is the jenkins web root directory (mentioned in the /etc/default/jenkins file)
    @@ -64,13 +64,14 @@ http {

    location @jenkins {
    sendfile off;
    proxy_pass http://127.0.0.1:8080;
    proxy_read_timeout 90;
    proxy_redirect http://127.0.0.1:8080 https://jenkins.ajmoss.com;

    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_pass http://127.0.0.1:8080;
    proxy_read_timeout 90;
    proxy_redirect http:// https://;

    proxy_set_header X-Forwarded-Proto $scheme;
    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_max_temp_file_size 0;

    #this is the maximum upload size
  4. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -65,7 +65,8 @@ http {
    location @jenkins {
    sendfile off;
    proxy_pass http://127.0.0.1:8080;
    proxy_redirect default;
    proxy_read_timeout 90;
    proxy_redirect http://127.0.0.1:8080 https://jenkins.ajmoss.com;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
  5. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 1 addition and 7 deletions.
    8 changes: 1 addition & 7 deletions jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@ user nginx;
    worker_processes auto;

    error_log /var/log/nginx/error.log;

    pid /var/run/nginx.pid;


    @@ -50,18 +49,13 @@ http {
    error_log /var/log/nginx/jenkins.error.log;

    location ~ "^/static/[0-9a-fA-F]{8}\/(.*)$" {

    #rewrite all static files into requests to the root
    #E.g /static/12345678/css/something.css will become /css/something.css
    rewrite "^/static/[0-9a-fA-F]{8}\/(.*)" /$1 last;
    }

    location /userContent {
    #have nginx handle all the static requests to the userContent folder files
    #note : This is the $JENKINS_HOME dir
    root /var/lib/jenkins/;

    if (!-f $request_filename) {
    #this file does not exist, might be a directory or a /**view** url
    rewrite (.*) /$1 last;
    break;
    }
  6. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -46,8 +46,8 @@ http {
    #this is the jenkins web root directory (mentioned in the /etc/default/jenkins file)
    root /var/run/jenkins/war/;

    access_log /var/log/nginx/jenkins/access.log;
    error_log /var/log/nginx/jenkins/error.log;
    access_log /var/log/nginx/jenkins.access.log;
    error_log /var/log/nginx/jenkins.error.log;

    location ~ "^/static/[0-9a-fA-F]{8}\/(.*)$" {

  7. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,7 @@ http {


    ssl_protocols TLSv1;
    ssl_ciphers HIGH: !aNULL:!MD5;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    #this is the jenkins web root directory (mentioned in the /etc/default/jenkins file)
  8. kloudsamurai revised this gist Feb 13, 2016. 1 changed file with 57 additions and 16 deletions.
    73 changes: 57 additions & 16 deletions jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -30,17 +30,9 @@ http {

    gzip on;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    index index.html index.htm;

    server {
    listen 443;
    server_name localhost;
    root html;
    server_name jenkins.ajmoss.com;

    ssl on;
    ssl_certificate /opt/ssl/ssl.crt;
    @@ -51,14 +43,63 @@ http {
    ssl_ciphers HIGH: !aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    #this is the jenkins web root directory (mentioned in the /etc/default/jenkins file)
    root /var/run/jenkins/war/;

    access_log /var/log/nginx/jenkins/access.log;
    error_log /var/log/nginx/jenkins/error.log;

    location ~ "^/static/[0-9a-fA-F]{8}\/(.*)$" {

    #rewrite all static files into requests to the root
    #E.g /static/12345678/css/something.css will become /css/something.css
    rewrite "^/static/[0-9a-fA-F]{8}\/(.*)" /$1 last;
    }

    location /userContent {
    #have nginx handle all the static requests to the userContent folder files
    #note : This is the $JENKINS_HOME dir
    root /var/lib/jenkins/;
    if (!-f $request_filename) {
    #this file does not exist, might be a directory or a /**view** url
    rewrite (.*) /$1 last;
    break;
    }
    sendfile on;
    }

    location @jenkins {
    sendfile off;
    proxy_pass http://127.0.0.1:8080;
    proxy_redirect default;

    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_max_temp_file_size 0;

    #this is the maximum upload size
    client_max_body_size 10m;
    client_body_buffer_size 128k;

    proxy_connect_timeout 90;
    proxy_send_timeout 90;
    proxy_read_timeout 90;

    proxy_buffer_size 4k;
    proxy_buffers 4 32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k;
    }

    location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Real-Port $server_port;
    proxy_set_header X-Real-Scheme $scheme;

    # Optional configuration to detect and redirect iPhones
    if ($http_user_agent ~* '(iPhone|iPod)') {
    rewrite ^/$ /view/iphone/ redirect;
    }

    try_files $uri @jenkins;
    }
    }
    }
  9. kloudsamurai created this gist Feb 12, 2016.
    64 changes: 64 additions & 0 deletions jenkins.nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    user nginx;
    worker_processes auto;

    error_log /var/log/nginx/error.log;

    pid /var/run/nginx.pid;


    events {
    worker_connections 1024;
    }

    http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    #keepalive_timeout 0;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    gzip on;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    index index.html index.htm;

    server {
    listen 443;
    server_name localhost;
    root html;

    ssl on;
    ssl_certificate /opt/ssl/ssl.crt;
    ssl_certificate_key /opt/ssl/ssl.key;


    ssl_protocols TLSv1;
    ssl_ciphers HIGH: !aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Real-Port $server_port;
    proxy_set_header X-Real-Scheme $scheme;
    }
    }
    }