[Conclusion] Adding a static website requires three concepts, as follows:

– /var/www/website source code

-/etc/nginx/sites-available/ Nginx server configuration file, port mapping IP mapping file

-/etc/nginx/sites-enabled/ nginx links to binary executable files, not folders

You need to operate in these three places

File structure:

– Front (React static build webpage)

-admin(React static build web page)

– API (Node Server dynamic, listening on port 8360)

front.domain.com
admin.domain.com
api.domain.com
Copy the code

Implementation method:

  1. All docker implementations
  • Nginx also starts with Docker
  • Front starts with Docker, installs Node and serve, and starts post-service

Facebook. Making. IO/create – fax…

  • Admin is static and can also be used with Node and serve or Express
  • The API starts and dependencies with Docker

The difficulty is: how to implement HTTPS, how to implement subdomain? Docker-compose is complicated to start. You can use this package github.com/jwilder/ngi… The setup is more complex and abandoned halfway. Other implementations are as follows: github.com/frankgo81/d…

  1. Build nginx server + Docker
  • DNS is mapped to the server IP address, and then through nginx server block, static, such as front.domain.com/var/www/front.mydomain.com/index.html mapping to the server address, in the same way the admin
  • Docker: localhost:8360; docker: localhost:8360; Docker: Localhost :8360; docker: Localhost :8360

This is the perfect solution for SSL and secondary domain names.

The first method is to look at the code without going into details. I want to focus on the second method.

Buy an Ubuntu server

Version:

ubuntu@VM-0-10-ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic
Copy the code

Install docker

Docs.docker.com/install/lin…

Docker-compose installation

Docs.docker.com/compose/ins…

Install nginx

www.digitalocean.com/community/t…

Very simple problem solving.

5. Map websites

www.digitalocean.com/community/t…

The /var/www/ folder was automatically added after nginx was installed

Note: need to have the location changes into a try_files uriuri uriuri / / index. The HTML or refresh the 404 error stackoverflow.com/questions/5…

This is to add a website, the following also needs to be added separately, the last picture is shown:

This is a normal static web page

Package the Docker API file

Start the docker – composer build/up

7. Add HTTPS

Certbot.eff.org/lets-encryp…

Very simple and automatically updates cert.

Download and save the certificate

Done !!!!!!!!!!!!!!!!!!!!!!