Nginx
Although Casdoor is a front-end back-end separation architecture, in the production environment, the back-end program still provides static file services for front-end files. Therefore, you can use reverse proxy software such as Nginx to proxy all traffic for the Casdoor domain and redirect it to the port monitored by the backend go program.
In this chapter you will learn how to use Nginx to reverse proxy your backend Go program, quickly start the Casdoor service.
1. Build front end static files
Now assume that you have downloaded Casdoor and completed the necessary configuration. If not, go to Get started section.
You only needs to build static files, like this:
- Yarn
- npm
yarn install && yarn run build
npm install && npm run build
2. Run the back end program
go run main.go
Or build first:
go build && ./main
3. Configure and run Nginx
vim /path/to/nginx/nginx.conf
Add a server:
server {
listen 80;
server_name YOUR_DOMAIN_NAME;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass http://127.0.0.1:8000;
}
}
Then restart your nginx process, run:
nginx -s reload
4. Test
Visit http://YOUR_DOMAIN_NAME
in your favorite browser.