Last active
December 23, 2024 07:50
-
-
Save gmhafiz/8fbee58508bcd8c30ecd24f7018d0aa6 to your computer and use it in GitHub Desktop.
reverse proxy vue using nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Add a custom DNS entry | |
# File: /etc/hosts | |
127.0.0.1 site.test | |
2. In nginx conf file, tell it to reverse proxy all requests from site.test to http://localhost:3000 | |
# File: /etc/nginx/sites-enabled/site.conf | |
server { | |
listen 443 ssl; | |
server_name site.test; | |
ssl_certificate /etc/nginx/ssl/site.test.crt; # for TLS, otherwise remove | |
ssl_certificate_key /etc/nginx/ssl/site.test.key; | |
access_log /var/log/nginx/access.log main; | |
error_log /var/log/nginx/error.log; | |
location / { | |
proxy_pass http://localhost:3000; | |
proxy_ssl_server_name on; | |
proxy_http_version 1.1; | |
} | |
Then access with | |
https://site.test | |
or | |
http://site.test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment