Welcome! Log In Create A New Profile

Advanced

Nginx as reverse proxy for web app for containers on azure

Posted by revakkyh 
Nginx as reverse proxy for web app for containers on azure
May 15, 2020 05:47AM
Hi!

I have been following this guide: https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71
to set up ssl for a web app for containers on azure but have run into some problems i just can't figure out..

I have used the script provided in the guide to generate a certificate for my domain and gotten if working without any issues when i run docker compose locally but when i deploy it to azure it wont work.

I get a too many redirects error in my browser so my guess is that my nginx config is faulty

Can anyone give me some pointers on what might be the issue?

These are my nginx config and dockerfiles:

nginx config:

worker_processes 1;
events {
worker_connections 1000;
}

http {

server {
listen 80;
server_name mysite.se www.mysite.se;
server_tokens off;

location /.well-known/acme-challenge/ {
root /var/www/certbot;
}

location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
server_name mysite.se www.mysite.se;
server_tokens off;

ssl_certificate /etc/letsencrypt/live/xx--xxx-xx.se/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xx--xxx-xxx.se/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
large_client_header_buffers 4 32k;

index index.html index.htm;
include /etc/nginx/mime.types;
root /usr/share/nginx/html;

location / {
try_files $uri $uri/ /index.html;
}
}
}
-------------------

My docker-compose:

version: "3.4"
services:
app-service:
build:
context: AVC/ClientApp
dockerfile: production.dockerfile
environment:
- NODE_ENV=development
ports:
- 80:80
- 443:443
volumes:
- .${WEBAPP_STORAGE_HOME}/certbot/conf:/etc/letsencrypt
- .${WEBAPP_STORAGE_HOME}/certbot/www:/var/www/certbot
depends_on:
- api-service
command: [nginx, "-g", "daemon off;"]

----
dockerfile:

FROM node:latest as node
EXPOSE 80
EXPOSE 443

WORKDIR /app
RUN npm i -g @angular/cli@latest
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm install
COPY . .
RUN ng build --prod --buildOptimizer

FROM nginx:alpine
VOLUME /var/cache/nginx

COPY --from=node /app/dist /usr/share/nginx/html
COPY ./config/nginx.conf /etc/nginx/nginx.conf
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 98
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready