https://github.com/munirmuratovic/react-dotnet-nginx-dockerized
Nginx SSL Reverse Proxy with React.js frontend and .NET Core backend, all loosely coupled services running as Docker containers
https://github.com/munirmuratovic/react-dotnet-nginx-dockerized
docker dotnet-core nginx reactjs
Last synced: 3 months ago
JSON representation
Nginx SSL Reverse Proxy with React.js frontend and .NET Core backend, all loosely coupled services running as Docker containers
- Host: GitHub
- URL: https://github.com/munirmuratovic/react-dotnet-nginx-dockerized
- Owner: munirmuratovic
- Created: 2021-06-16T22:51:46.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-06-04T21:09:18.000Z (about 4 years ago)
- Last Synced: 2025-10-07T02:43:52.657Z (9 months ago)
- Topics: docker, dotnet-core, nginx, reactjs
- Language: C#
- Homepage:
- Size: 1.31 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React + Nginx + ASP.NET Core WEB API
NOTE: Before docker-compose up, please go to frontend, npm install then npm run build, then remove node_modules folder! (rm -r node_modules/)
Web App Deployment with docker, Nginx and SSL
## ubuntu+nginx+certbot - Dockerfile
```Dockerfile
FROM ubuntu:18.04
RUN apt update -y \
&& apt install nginx -y \
&& apt-get install software-properties-common -y \
&& add-apt-repository ppa:certbot/certbot -y \
&& apt-get update -y \
&& apt-get install python-certbot-nginx -y \
&& apt-get clean
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]
```
## Nginx Configuration - default.conf
```
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name meetnet.net www.meetnet.net;
location / {
root /var/www/html;
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://server/api/;
}
}
```
## docker-compose.yml
```yaml
version: '3.8'
services:
server:
image: node:12-alpine
ports:
- '8080:80'
volumes:
- ./server:/root/server
env_file:
- ./deploy/server.env
entrypoint: sh /root/server/start_server.sh
frontend:
build:
context: ./deploy
dockerfile: Dockerfile
ports:
- '80:80'
- '443:443'
volumes:
- ./frontend/build:/var/www/html
- ./deploy/default.conf:/etc/nginx/sites-available/default
- ./letsencrypt:/etc/letsencrypt
depends_on:
- server
```
`./letsencrypt` will contain the data, you won't need to setup SSL again after restarting/recreating the containers.
## Deploy and Setup SSL
```bash
docker-compose up -d
docker exec -it bash # bash into the nginx container
certbot --nginx -d -d # setup SSL certificate
```