# 1)
brew install vapor
# 2)
vapor new demo_swift_server_vapor_auth --template https://github.com/Guang1234567/vapor4_auth_template
repository/docker/lihansey/vapor4_auth_template
# 1)
╰─ docker pull lihansey/vapor4_auth_template:latest
# 2)
╰─ docker-compose up app
# 3) create database scheme and tables
╰─ docker-compose up migrate
# 4)
╰─ broswer http://127.0.0.1:8080
-
Certificate generation
Also because HTTP/2 is a secure protocol by default, you'll need your own SSL certificate. You can generate a self-signed cert.pem and a cert.key files with the following command (fill out the details with some fake data and press enter).
cd ./etc/nginx openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout cert.key -out cert.pem
-
install
nginx
https://docs.vapor.codes/4.0/deploy/nginx/
brew install nginx
-
cfg ngnix
vapor4_auth_template/etc/nginx/nginx.conf
Lines 117 to 153 in b0f2b7e
- start
nginx
nginx -c ~/dev_kit/workspace/demo_swift_server_vapor_auth/etc/nginx/nginx.conf
- start
-
check
HTTPS
EnvUsing your smartphone which under the same wifi with your macbookpro to browse:
http://<your macOS IP>:8080/ For example (Dont copy!): http://10.0.0.28:8080/
then will see:
Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com. Thank you for using nginx.
-
other command for nginx
# quit nginx nginx -s quit # dry run and test nginx -c ~/dev_kit/workspace/demo_swift_server_vapor_auth/etc/nginx/nginx.conf -t
swift build -Xswiftc -g -c debug && .build/debug/Run --log debug --env development.custom_name
note:
issue: Crashed when calling Bcrypt.hash on
- macOS catalina 10.15.6 with xcode 11.6
- macOS catalina 10.15.5 with xcode 11.5
then access vapor web application via HTTPS
- on smartphone
https://10.0.0.28/
or
https://10.0.0.28:443/
- on PC
https://127.0.0.1/
or
https://127.0.0.1:443/
then both will see:
It works!
// in the process ... ( I dont have the Ubuntu -_-|| )