-
-
Save officialmofabs/6162c3a55ba6a18450d2d4108f85ff24 to your computer and use it in GitHub Desktop.
Self signed ssl nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory=$true)] | |
[string]$solutionName, | |
[Parameter(Mandatory=$true)] | |
[string]$solutionPath | |
) | |
function Test-SPSolutionDeployed([string]$solutionName) | |
{ | |
$solution = Get-SPSolution -Identity $solutionName -ErrorAction SilentlyContinue | |
if (-not($solution)) | |
{ | |
Write-Host "Unable to find solution '$solutionName'." | |
return $false | |
} | |
$lastOperationResult = $solution.LastOperationResult | |
$lastOperationDetails = $solution.LastOperationDetails | |
Write-Host "Solution '$solutionName' last operation result is '$lastOperationResult'." | |
Write-Host "Details: $lastOperationDetails" | |
return $solution.Deployed | |
} | |
function Test-SPSolutionLastDeploymentSucceeded([string]$solutionName) | |
{ | |
# Get the solution again to make sure all deployment info is up-to-date | |
$solution = Get-SPSolution -Identity $solutionName -ErrorAction SilentlyContinue | |
if (-not($solution)) | |
{ | |
Write-Host "Unable to find solution '$solutionName'." -ForegroundColor Red | |
return $false | |
} | |
# Check the solution deployment's last operation result was successful | |
$lastOperationResult = $solution.LastOperationResult | |
if ($lastOperationResult -eq [Microsoft.SharePoint.Administration.SPSolutionOperationResult]::DeploymentSucceeded) | |
{ | |
Write-Host "Solution '$solutionName' last deployment succeeded." | |
return $true | |
} | |
$lastOperationDetails = $solution.LastOperationDetails | |
Write-Host "Solution '$solutionName' last operation result is '$lastOperationResult'." -ForegroundColor Red | |
Write-Host "Details: $lastOperationDetails" -ForegroundColor Red | |
return $false | |
} | |
function Add-LocalSPSolution([string]$solutionPath, [string]$solutionName) | |
{ | |
$solution = Get-SPSolution -Identity $solutionName -ErrorAction SilentlyContinue | |
if (-not($solution)) | |
{ | |
Write-Host "Unable to find solution '$solutionName'. > Add solution $solutionName to solution store" | |
Add-SPSolution -LiteralPath $solutionPath -ErrorAction Stop | |
}else{ | |
Write-Host "Solution '$solutionName' already exists in solution store" | |
} | |
} | |
function Wait-SPSolutionDeployed([string]$solutionName, [int]$timeout = 300) | |
{ | |
$solution = Get-SPSolution -Identity $solutionName -ErrorAction SilentlyContinue | |
if (-not($solution)) | |
{ | |
Write-Host "Unable to find solution '$solutionName'." -ForegroundColor Red | |
throw "Unable to find solution '$solutionName'." | |
} | |
$deployed = $False | |
$startTime = Get-Date | |
while ($deployed -eq $False) { | |
$s = Get-SPSolution -Identity $solution | |
if ($s.Deployed -eq $True -And $s.JobExists -eq $False) { | |
$deployed = $True | |
} | |
$currentTime = Get-Date | |
$elapsedTime = $currentTime - $startTime | |
if ($elapsedTime.TotalSeconds -gt $timeout) { | |
Write-Host "Solution '$solutionName' deployment timed out." -ForegroundColor Red | |
return $false | |
} | |
write-host "Waiting for solution '$solutionName' to be deployed..." | |
Start-Sleep -s 5 | |
} | |
return $true | |
} | |
function Deploy-LocalSPSolution([string]$solutionPath, [string]$solutionName) | |
{ | |
if(Test-SPSolutionDeployed($solutionName) -eq $false){ | |
Write-Host "Solution '$solutionName' is not deployed. Deploying..." | |
Install-SPSolution –Identity $solutionName -GACDeployment -Force -ErrorAction Stop -Verbose | |
} | |
else | |
{ | |
write-host "Solution '$solutionName' is already deployed, updating..." | |
Update-SPSolution -LiteralPath $solutionPath -Identity $solutionName -Force -GACDeployment -ErrorAction Stop -Verbose | |
} | |
Wait-SPSolutionDeployed($solutionName, 600) | |
write-host "Solution '$solutionName' is deployed." | |
} | |
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue | |
# TODO: check for solutionpath existence | |
# add solution to solution store if not already there | |
Add-LocalSPSolution($solutionPath, $solutionName) | |
# deploy solution | |
Deploy-LocalSPSolution($solutionPath, $solutionName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
nginx: | |
image: nginx:alpine | |
command: > | |
sh -c " | |
apk add openssl && | |
mkdir -p /var/www/backend/certs/ && | |
cd /var/www/backend/certs/ && | |
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -subj \"/C=/ST=/L=/O=/CN=\" -keyout default.key -out default.crt && | |
nginx -g \"daemon off;\"" | |
volumes: | |
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro | |
restart: unless-stopped | |
ports: | |
- 443:443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream bar { | |
server somewhere | |
} | |
server { | |
listen 443 ssl http2; | |
ssl_certificate /var/www/backend/certs/default.crt; | |
ssl_certificate_key /var/www/backend/certs/default.key; | |
location /foo/ { | |
proxy_pass http://bar/; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment