diff --git a/Docker-files/app/Dockerfile b/Docker-files/app/Dockerfile new file mode 100644 index 000000000..45fda3a0e --- /dev/null +++ b/Docker-files/app/Dockerfile @@ -0,0 +1,12 @@ +ROM openjdk:8 AS BUILD_IMAGE +RUN apt update && apt install maven -y +RUN git clone https://github.com/davismatrix/vprofile-project.git +RUN cd vprofile-project && git checkout docker && mvn install + +FROM tomcat:9-jre11 + +RUN rm -rf /usr/local/tomcat/webapps/* +COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war + +EXPOSE 8080 +CMD [ "catalina.sh", "run" ] diff --git a/Docker-files/app/multistage/Dockerfile b/Docker-files/app/multistage/Dockerfile new file mode 100644 index 000000000..098065c58 --- /dev/null +++ b/Docker-files/app/multistage/Dockerfile @@ -0,0 +1,13 @@ +FROM openjdk:8 AS BUILD_IMAGE +RUN apt update && apt install maven -y +RUN git clone https://github.com/davismatrix/vprofile-project.git +RUN cd vprofile-project && git checkout docker && mvn install + +FROM tomcat:9-jre11 + +RUN rm -rf /usr/local/tomcat/webapps/* +COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war + +EXPOSE 8080 +CMD [ "catalina.sh", "run" ] + diff --git a/Docker-files/db/Dockerfile b/Docker-files/db/Dockerfile new file mode 100644 index 000000000..e69de29bb diff --git a/Docker-files/web/Dockerfile b/Docker-files/web/Dockerfile new file mode 100644 index 000000000..e69de29bb diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index be7508be5..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,121 +0,0 @@ -pipeline { - - agent any -/* - tools { - maven "maven3" - } -*/ - environment { - NEXUS_VERSION = "nexus3" - NEXUS_PROTOCOL = "http" - NEXUS_URL = "172.31.40.209:8081" - NEXUS_REPOSITORY = "vprofile-release" - NEXUS_REPO_ID = "vprofile-release" - NEXUS_CREDENTIAL_ID = "nexuslogin" - ARTVERSION = "${env.BUILD_ID}" - } - - stages{ - - stage('BUILD'){ - steps { - sh 'mvn clean install -DskipTests' - } - post { - success { - echo 'Now Archiving...' - archiveArtifacts artifacts: '**/target/*.war' - } - } - } - - stage('UNIT TEST'){ - steps { - sh 'mvn test' - } - } - - stage('INTEGRATION TEST'){ - steps { - sh 'mvn verify -DskipUnitTests' - } - } - - stage ('CODE ANALYSIS WITH CHECKSTYLE'){ - steps { - sh 'mvn checkstyle:checkstyle' - } - post { - success { - echo 'Generated Analysis Result' - } - } - } - - stage('CODE ANALYSIS with SONARQUBE') { - - environment { - scannerHome = tool 'sonarscanner4' - } - - steps { - withSonarQubeEnv('sonar-pro') { - sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ - -Dsonar.projectName=vprofile-repo \ - -Dsonar.projectVersion=1.0 \ - -Dsonar.sources=src/ \ - -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ - -Dsonar.junit.reportsPath=target/surefire-reports/ \ - -Dsonar.jacoco.reportsPath=target/jacoco.exec \ - -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' - } - - timeout(time: 10, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true - } - } - } - - stage("Publish to Nexus Repository Manager") { - steps { - script { - pom = readMavenPom file: "pom.xml"; - filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); - echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" - artifactPath = filesByGlob[0].path; - artifactExists = fileExists artifactPath; - if(artifactExists) { - echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION"; - nexusArtifactUploader( - nexusVersion: NEXUS_VERSION, - protocol: NEXUS_PROTOCOL, - nexusUrl: NEXUS_URL, - groupId: pom.groupId, - version: ARTVERSION, - repository: NEXUS_REPOSITORY, - credentialsId: NEXUS_CREDENTIAL_ID, - artifacts: [ - [artifactId: pom.artifactId, - classifier: '', - file: artifactPath, - type: pom.packaging], - [artifactId: pom.artifactId, - classifier: '', - file: "pom.xml", - type: "pom"] - ] - ); - } - else { - error "*** File: ${artifactPath}, could not be found"; - } - } - } - } - - - } - - -} diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile new file mode 100644 index 000000000..af1f35b6f --- /dev/null +++ b/ProdPipeline/Jenkinsfile @@ -0,0 +1,37 @@ +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] +pipeline { + agent any + tools { + maven "MAVEN3" + jdk "OracleJDK8" + } + + environment { + + cluster = "vproprod" + service = "vproappprodsvc" + } + + stages { + + stage('Deploy to ECS PROD') { + steps { + withAWS(credentials: 'awscreds', region: 'ca-central-1') { + sh 'aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment' + } + } + } + } + + post { + always { + echo 'Slack Notification.' + slackSend channel: '#vappcicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n Job build took ${currentBuild.durationString} \n More info at: ${env.BUILD_URL}" + } + } +} diff --git a/StagePipeline/Jenkinsfile b/StagePipeline/Jenkinsfile new file mode 100644 index 000000000..42410a5d8 --- /dev/null +++ b/StagePipeline/Jenkinsfile @@ -0,0 +1,140 @@ +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] +pipeline { + agent any + tools { + maven "MAVEN3" + jdk "OracleJDK8" + } + + environment { + SNAP_REPO = 'vprofile-snapshot' + NEXUS_USER = 'admin' + NEXUS_PASS = 'admin1234' + RELEASE_REPO = 'vprofile-release' + CENTRAL_REPO = 'vpro-maven-central' + NEXUSIP = '192.168.56.14' + NEXUSPORT = '8081' + NEXUS_GRP_REPO = 'vpro-maven-group' + NEXUS_LOGIN = 'nexuslogin' + SONARSERVER = 'sonarserver' + SONARSCANNER = 'sonarscanner' + registryCredential = 'ecr:ca-central-1:awscreds' + appRegistry = '310358171212.dkr.ecr.ca-central-1.amazonaws.com/vprofileappimg' + vprofileRegistry = 'https://310358171212.dkr.ecr.ca-central-1.amazonaws.com' + cluster = "vprostaging" + service = "vproappstagesvc" + } + + stages { + stage('build') { + steps { + sh 'mvn -s settings.xml -DskipTests install' + } + post { + success { + echo "Now Archiving." + archiveArtifacts artifacts: '**/*.war' + } + } + } + + stage('Test') { + steps { + sh 'mvn -s settings.xml test' + } + } + + stage('Checkstyle Analysis') { + steps { + sh 'mvn -s settings.xml checkstyle:checkstyle' + } + } + + stage('Sonar Analysis') { + environment { + scannerHome = tool "${SONARSCANNER}" + } + steps { + withSonarQubeEnv("${SONARSERVER}") { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } + } + } + + stage('Quality Gate') { + steps { + timeout(time: 1, unit: 'HOURS') { + // Parameter indicates whether to set pipeline to UNSTABLE + // true = set pipeline to UNSTABLE, false = don't + waitForQualityGate abortPipeline: true + } + } + } + + stage ('UploadArtifact') { + steps { + nexusArtifactUploader( + nexusVersion: 'nexus3', + protocol: 'http', + nexusUrl: "${NEXUSIP}:${NEXUSPORT}", + groupId: 'QA', + version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}", + repository: "${RELEASE_REPO}", + credentialsId: "${NEXUS_LOGIN}", + artifacts: [ + [artifactId: 'vproapp', + classifier: '', + file: 'target/vprofile-v2.war', + type: 'war'] + ] + ) + } + } + + stage('Build App Image') { + steps { + script { + dockerImage = docker.build( appRegistry + ":$BUILD_NUMBER", "./Docker-files/app/multistage/" ) + } + } + } + + stage('Upload App Image') { + steps { + script { + docker.withRegistry( vprofileRegistry, registryCredential) { + dockerImage.push("$BUILD_NUMBER") + dockerImage.push('latest') + } + } + } + } + + stage('Deploy to ECS staging') { + steps { + withAWS(credentials: 'awscreds', region: 'ca-central-1') { + sh 'aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment' + } + } + } + } + + post { + always { + echo 'Slack Notification.' + slackSend channel: '#vappcicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n Job build took ${currentBuild.durationString} \n More info at: ${env.BUILD_URL}" + } + } +} diff --git a/kubeadm/Vagrantfile b/kubeadm/Vagrantfile new file mode 100644 index 000000000..691d67f8f --- /dev/null +++ b/kubeadm/Vagrantfile @@ -0,0 +1,55 @@ +Vagrant.configure("2") do |config| + config.hostmanager.enabled = true + config.hostmanager.manage_host = true + config.vm.define "kops" do |kops| + kops.vm.box = "ubuntu/bionic64" + kops.vm.network "private_network", ip: "192.168.56.2" + kops.vm.provider "virtualbox" do |vb| + vb.name = "kops" + vb.memory = 2048 + vb.cpus = 2 + end + kops.vm.hostname = "kops" + #kops.vm.provision "shell", path: "kubemaster-init.sh" + end + +# config.vm.define "kubemaster" do |kubemaster| +# kubemaster.vm.box = "ubuntu/bionic64" +# kubemaster.vm.network "private_network", ip: "192.168.56.2" +# kubemaster.vm.provider "virtualbox" do |vb| +# vb.name = "kubemaster" +# vb.memory = 2048 +# vb.cpus = 2 +# end +# kubemaster.vm.hostname = "kubemaster" +# kubemaster.vm.provision "shell", path: "kubemaster-init.sh" +# end + + #config.hostmanager.enabled = true + #config.hostmanager.manage_host = true + #config.vm.define "kubenode1" do |kubenode1| + # kubenode1.vm.box = "ubuntu/bionic64" + # kubenode1.vm.network "private_network", ip: "192.168.56.3" + # kubenode1.vm.provider "virtualbox" do |vb| + # vb.name = "kubenode1" + # vb.memory = 2048 + # vb.cpus = 2 + # end + # kubenode1.vm.hostname = "kubenode1" + # kubenode1.vm.provision "shell", path: "kubenode1-init.sh" + # end + + # config.hostmanager.enabled = true + # config.hostmanager.manage_host = true + # config.vm.define "kubenode2" do |kubenode2| + # kubenode2.vm.box = "ubuntu/bionic64" + # kubenode2.vm.network "private_network", ip: "192.168.56.3" + # kubenode2.vm.provider "virtualbox" do |vb| + # vb.name = "kubenode2" + # vb.memory = 2048 + # vb.cpus = 2 + # end + # kubenode2.vm.hostname = "kubenode2" + # kubenode2.vm.provision "shell", path: "kubenode2-init.sh" + # end + end \ No newline at end of file diff --git a/kubeadm/cltjoincommand.sh b/kubeadm/cltjoincommand.sh new file mode 100755 index 000000000..e69de29bb diff --git a/kubeadm/kubemaster-init.sh b/kubeadm/kubemaster-init.sh new file mode 100644 index 000000000..7ddfb76f3 --- /dev/null +++ b/kubeadm/kubemaster-init.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +## Set variables values +MASTER_IP=192.168.56.2 + +lsmod | grep br_netfilter +sudo modprobe br_netfilter +lsmod | grep br_netfilter +cat <> /dev/null +if [ $? -eq 0 ] +then + # (Install Docker CE) + ## Set up the repository + ### Install required packages + yum install -y yum-utils device-mapper-persistent-data lvm2 + ## Add the Docker repository + yum-config-manager --add-repo \ + https://download.docker.com/linux/centos/docker-ce.repo + # Install Docker CE + yum update -y && yum install -y \ + containerd.io-1.2.13 \ + docker-ce-19.03.11 \ + docker-ce-cli-19.03.11 + ## Create /etc/docker + mkdir /etc/docker + # Set up the Docker daemon + cat > /etc/docker/daemon.json < /etc/docker/daemon.json <> /dev/null +if [ $? -eq 0 ] +then + cat < /tmp/kubeadm_out.log +sleep 360 +/vagrant/set-kubeconfig.sh +sudo kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" +kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" +sleep 60 +sudo cat /tmp/kubeadm_out.log | grep -A1 'kubeadm join' > /vagrant/cltjoincommand.sh +sudo chmod +x /vagrant/cltjoincommand.sh \ No newline at end of file diff --git a/kubeadm/kubenode1-init.sh b/kubeadm/kubenode1-init.sh new file mode 100644 index 000000000..b0f4df320 --- /dev/null +++ b/kubeadm/kubenode1-init.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +lsmod | grep br_netfilter +sudo modprobe br_netfilter +lsmod | grep br_netfilter +cat <> /dev/null +if [ $? -eq 0 ] +then + # (Install Docker CE) + ## Set up the repository + ### Install required packages + yum install -y yum-utils device-mapper-persistent-data lvm2 + ## Add the Docker repository + yum-config-manager --add-repo \ + https://download.docker.com/linux/centos/docker-ce.repo + # Install Docker CE + yum update -y && yum install -y \ + containerd.io-1.2.13 \ + docker-ce-19.03.11 \ + docker-ce-cli-19.03.11 + ## Create /etc/docker + mkdir /etc/docker + # Set up the Docker daemon + cat > /etc/docker/daemon.json < /etc/docker/daemon.json <> /dev/null +if [ $? -eq 0 ] +then + cat <> /dev/null +if [ $? -eq 0 ] +then + # (Install Docker CE) + ## Set up the repository + ### Install required packages + yum install -y yum-utils device-mapper-persistent-data lvm2 + ## Add the Docker repository + yum-config-manager --add-repo \ + https://download.docker.com/linux/centos/docker-ce.repo + # Install Docker CE + yum update -y && yum install -y \ + containerd.io-1.2.13 \ + docker-ce-19.03.11 \ + docker-ce-cli-19.03.11 + ## Create /etc/docker + mkdir /etc/docker + # Set up the Docker daemon + cat > /etc/docker/daemon.json < /etc/docker/daemon.json <> /dev/null +if [ $? -eq 0 ] +then + cat <1.8.2.RELEASE 4.3.11.Final 5.2.1.Final - 8.0.32 + 8.0.22 1.4 1.2 4.10 @@ -208,4 +208,10 @@ + + + ${NEXUS_GRP_REPO} + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS_GRP_REPO}/ + + diff --git a/settings.xml b/settings.xml new file mode 100644 index 000000000..8e11c6e8c --- /dev/null +++ b/settings.xml @@ -0,0 +1,38 @@ + + + + + + ${SNAP_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} + + + ${RELEASE_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} + + + ${CENTRAL_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} + + + ${NEXUS_GRP_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} + + + + + + ${CENTRAL_REPO} + ${CENTRAL_REPO} + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS_GRP_REPO}/ + * + + + + diff --git a/userdata/jenkins-setup.sh b/userdata/jenkins-setup.sh new file mode 100644 index 000000000..7c849fc68 --- /dev/null +++ b/userdata/jenkins-setup.sh @@ -0,0 +1,15 @@ +#!/bin/bash +sudo apt update +sudo apt install openjdk-11-jdk -y +sudo apt install maven wget unzip -y + +curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \ + /usr/share/keyrings/jenkins-keyring.asc > /dev/null + +echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ + https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ + /etc/apt/sources.list.d/jenkins.list > /dev/null + +sudo apt-get update +sudo apt-get install jenkins -y +### diff --git a/userdata/nexus-setup.sh b/userdata/nexus-setup.sh new file mode 100644 index 000000000..4d0c48fc4 --- /dev/null +++ b/userdata/nexus-setup.sh @@ -0,0 +1,38 @@ +#!/bin/bash +yum install java-1.8.0-openjdk.x86_64 wget -y +mkdir -p /opt/nexus/ +mkdir -p /tmp/nexus/ +cd /tmp/nexus/ +NEXUSURL="https://download.sonatype.com/nexus/3/latest-unix.tar.gz" +wget $NEXUSURL -O nexus.tar.gz +sleep 10 +EXTOUT=`tar xzvf nexus.tar.gz` +NEXUSDIR=`echo $EXTOUT | cut -d '/' -f1` +sleep 5 +rm -rf /tmp/nexus/nexus.tar.gz +cp -r /tmp/nexus/* /opt/nexus/ +sleep 5 +useradd nexus +chown -R nexus.nexus /opt/nexus +cat <> /etc/systemd/system/nexus.service +[Unit] +Description=nexus service +After=network.target + +[Service] +Type=forking +LimitNOFILE=65536 +ExecStart=/opt/nexus/$NEXUSDIR/bin/nexus start +ExecStop=/opt/nexus/$NEXUSDIR/bin/nexus stop +User=nexus +Restart=on-abort + +[Install] +WantedBy=multi-user.target + +EOT + +echo 'run_as_user="nexus"' > /opt/nexus/$NEXUSDIR/bin/nexus.rc +systemctl daemon-reload +systemctl start nexus +systemctl enable nexus diff --git a/userdata/sonar-analysis-properties b/userdata/sonar-analysis-properties new file mode 100644 index 000000000..8751fe7fd --- /dev/null +++ b/userdata/sonar-analysis-properties @@ -0,0 +1,10 @@ +sonar.projectKey=vprofile +sonar.projectName=vprofile-repo +sonar.projectVersion=1.0 +sonar.sources=src/ +sonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ +sonar.junit.reportsPath=target/surefire-reports/ +sonar.jacoco.reportsPath=target/jacoco.exec +sonar.java.checkstyle.reportPaths=target/checkstyle-result.xml + + diff --git a/userdata/sonar-setup.sh b/userdata/sonar-setup.sh new file mode 100644 index 000000000..99a3a78b7 --- /dev/null +++ b/userdata/sonar-setup.sh @@ -0,0 +1,119 @@ +#!/bin/bash +cp /etc/sysctl.conf /root/sysctl.conf_backup +cat < /etc/sysctl.conf +vm.max_map_count=262144 +fs.file-max=65536 +ulimit -n 65536 +ulimit -u 4096 +EOT +cp /etc/security/limits.conf /root/sec_limit.conf_backup +cat < /etc/security/limits.conf +sonarqube - nofile 65536 +sonarqube - nproc 409 +EOT + +sudo apt-get update -y +sudo apt-get install openjdk-11-jdk -y +sudo update-alternatives --config java + +java -version + +sudo apt update +wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - + +sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' +sudo apt install postgresql postgresql-contrib -y +#sudo -u postgres psql -c "SELECT version();" +sudo systemctl enable postgresql.service +sudo systemctl start postgresql.service +sudo echo "postgres:admin123" | chpasswd +runuser -l postgres -c "createuser sonar" +sudo -i -u postgres psql -c "ALTER USER sonar WITH ENCRYPTED PASSWORD 'admin123';" +sudo -i -u postgres psql -c "CREATE DATABASE sonarqube OWNER sonar;" +sudo -i -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE sonarqube to sonar;" +systemctl restart postgresql +#systemctl status -l postgresql +netstat -tulpena | grep postgres +sudo mkdir -p /sonarqube/ +cd /sonarqube/ +sudo curl -O https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-8.3.0.34182.zip +sudo apt-get install zip -y +sudo unzip -o sonarqube-8.3.0.34182.zip -d /opt/ +sudo mv /opt/sonarqube-8.3.0.34182/ /opt/sonarqube +sudo groupadd sonar +sudo useradd -c "SonarQube - User" -d /opt/sonarqube/ -g sonar sonar +sudo chown sonar:sonar /opt/sonarqube/ -R +cp /opt/sonarqube/conf/sonar.properties /root/sonar.properties_backup +cat < /opt/sonarqube/conf/sonar.properties +sonar.jdbc.username=sonar +sonar.jdbc.password=admin123 +sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube +sonar.web.host=0.0.0.0 +sonar.web.port=9000 +sonar.web.javaAdditionalOpts=-server +sonar.search.javaOpts=-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError +sonar.log.level=INFO +sonar.path.logs=logs +EOT + +cat < /etc/systemd/system/sonarqube.service +[Unit] +Description=SonarQube service +After=syslog.target network.target + +[Service] +Type=forking + +ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start +ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop + +User=sonar +Group=sonar +Restart=always + +LimitNOFILE=65536 +LimitNPROC=4096 + + +[Install] +WantedBy=multi-user.target +EOT + +systemctl daemon-reload +systemctl enable sonarqube.service +#systemctl start sonarqube.service +#systemctl status -l sonarqube.service +apt-get install nginx -y +rm -rf /etc/nginx/sites-enabled/default +rm -rf /etc/nginx/sites-available/default +cat < /etc/nginx/sites-available/sonarqube +server{ + listen 80; + server_name sonarqube.groophy.in; + + access_log /var/log/nginx/sonar.access.log; + error_log /var/log/nginx/sonar.error.log; + + proxy_buffers 16 64k; + proxy_buffer_size 128k; + + location / { + proxy_pass http://127.0.0.1:9000; + proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; + proxy_redirect off; + + 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_set_header X-Forwarded-Proto http; + } +} +EOT +ln -s /etc/nginx/sites-available/sonarqube /etc/nginx/sites-enabled/sonarqube +systemctl enable nginx.service +#systemctl restart nginx.service +sudo ufw allow 80,9000,9001/tcp + +echo "System reboot in 30 sec" +sleep 30 +reboot