Skip to content

Instantly share code, notes, and snippets.

@opentokix
Created November 13, 2018 08:31
Show Gist options
  • Save opentokix/212eafd68d392296da9b7112f6aefc89 to your computer and use it in GitHub Desktop.
Save opentokix/212eafd68d392296da9b7112f6aefc89 to your computer and use it in GitHub Desktop.
nginx::nginx_upstreams:
'jenkins':
ensure: present
members:
- localhost:8080
nginx::nginx_locations:
'jenkins':
location: '~ "^/jenkins/(.*)$"'
proxy_read_timeout: 90s
proxy: 'http://jenkins$uri$is_args$args'
proxy_set_header:
- "JENKINS_URL https://foo.bar.com"
- "Host $host"
- "X-Real-IP $remote_addr"
- "X-Forwarded-For $proxy_add_x_forwarded_for"
server: foo.bar.com
'app':
location: '/'
www_root: '/app/php-app'
server: foo.bar.com
nginx::nginx_servers:
'foo.bar.com':
server_name:
- 'foo.bar.com'
listen_port: 443
ssl: true
ssl_cert: '/usr/local/share/foo.bar.com.crt'
ssl_key: '/usr/local/share/foo.bar.com.key'
index_files: []
@alexjfisher
Copy link

class { 'nginx':
  nginx_upstreams => {
    'jenkins' =>
      {
        'ensure'   => present,
        'members'  => [ 'localhost:8080' ],
      }
  },
  nginx_locations => {
    'jenkins' => {
      'location'           => '~ "^/jenkins/(.*)$"',
      'server'             => 'foo.bar.com',
      'proxy_read_timeout' => '90s',
      'proxy'              => 'http://jenkins$uri$is_args$args',
      'proxy_set_header'   => [
        'JENKINS_URL https://foo.bar.com',
        'Host $host',
        'X-Real-IP $remote_addr',
        'X-Forwarded-For $proxy_add_x_forwarded_for',
      ],
      #### YOU NEED TO ADD THESE ####
      'ssl' => true,
      'ssl_only' => true,
      ###############################
    },
    'app'     => {
      'location' => '/',
      'www_root' => '/app/php-app',
      'server'   => 'foo.bar.com',
      #### YOU NEED TO ADD THESE ####
      'ssl' => true,
      'ssl_only' => true,
      ###############################
    },
  },
  nginx_servers   => {
    'foo.bar.com' =>
      {
        server_name => [ 'foo.bar.com' ],
        listen_port => 443,
        ssl         => true,
        ssl_cert    => '/usr/local/share/foo.bar.com.crt',
        ssl_key     => '/usr/local/share/foo.bar.com.key',
        index_files => [],
        ### AND THIS #########
        use_default_location => false,
        ######################
      },
  },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment