Xcode Integration Server OTA Reverse Proxy Nginx - mtjddnr/lab GitHub Wiki

#Nginx + Reverse Proxy + OS X Server[Xcode Server]

Setup

Internet -> [443] Router (Port Forwarding) -> [443]Nginx Server(Has HTTPS certificate) -> [443]Mac Mini (OS X Server, Xcode Server)

(StartSSL certificate is used)

Xcode Server uses 20300(HTTP), 20343(HTTPS) ports

Problem

  1. Enter Xcode Server WEB
  • Select Bot
  • hit Install button
  • It will ask to install certificate if first time. Install it and go back to webpage.
  • hit Install button again
  • Alert message "Cannot connect to server"

How OTA works

  1. When hit Install button, it navigates to https://<DOMAIN>/xcode/internal/api/integrations/<UNIQUE ID>/install_product
  • It returns status 302 to new location: itms-services://?action=download-manifest&url=https://<DOMAIN>:20343/api/integrations/<UNIQUE ID>/<RECENT Integrated ID>/install_manifest.plist
  • itms-services URL Schema calls iOS device to run installation.
  • iOS downloads install_manifest.plist then based on plist information, it selects right IPA URL
  • https://<DOMAIN>:20343/api/assets/token/<RECENT Integrated ID>/<UNIQUE ID>-<Bot Name>/<Intergation #>/<Product Name>-<Device Model>.ipa
  • Download & Install

Analysis

  • On Step 2, it returns URL <DOMAIN>:20343. Port number 20343 is not opened by Router(or Firewall)
  • Also path should be /xcode/internal/api/integrations/ not /api/integrations/

How to Fix

Location: /Library/Developer/XcodeServer/CurrentXcodeSymlink/Contents/Developer/usr/share/xcs/xcsd/

Modify constants.js Line 25

XCSProxiedAPIBasePath: '/xcode/api',

to

XCSProxiedAPIBasePath: '/xcode/internal/api',

Comment classes/fileClass.js Line 383

//host = host.split(':')[0] + ':' + k.XCSHTTPSPort; // force traffic over the HTTPS port

Modify classes/fileClass.js Line 384

var basePath = k.XCSAPIBasePath; // connection is direct to xcsd, always

to

var basePath = k.XCSProxiedAPIBasePath; // connection is direct to xcsd, always

Restart Server

⚠️ **GitHub.com Fallback** ⚠️