- add virtual host at C:\Windows\System32\drivers\etc\host (e.g. 127.0.0.1 virtualMV.test)
- download nginx at https://nginx.org/en/download.html and unzip some where
- follow this gist: https://gist.github.com/alicoskun/57acda07d5ab672a3c820da57b9531e3 to create key ssl
1: copy all file key ssl to drive C like: C:\ssl
2: open file nginx.conf in source nginx had unzip and add code below on property http
server{
listen 80;
server_name virtualMV.test;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3000; #chú ý đây: IP ra của npm run dev, mỗi máy mỗi khác
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# location /overview {
# proxy_pass http://127.0.0.1:3000$request_uri;
# proxy_redirect off;
# }
}
}
server{
listen 443 ssl;
server_name virtualMV.test;
ssl_certificate C:\ssl\certificate.pem; #key xao ssl
ssl_certificate_key C:\ssl\private.key; #key xao ssl
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3000; #chú ý đây: IP ra của npm run dev, mỗi máy mỗi khác
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# location /overview {
# proxy_pass http://127.0.0.1:3000$request_uri;
# proxy_redirect off;
# }
}
}
3: start nginx(run file exe first) or reload with command
start nginx
nginx -s reload