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
  1. yarn install && yarn run build
  1. npm install && npm run build

2. Run the back end program

  1. go run main.go

Or build first:

  1. go build && ./main

3. Configure and run Nginx

  1. vim /path/to/nginx/nginx.conf

Add a server:

  1. server {
  2. listen 80;
  3. server_name YOUR_DOMAIN_NAME;
  4. location / {
  5. proxy_set_header Host $http_host;
  6. proxy_set_header X-Real-IP $remote_addr;
  7. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  8. proxy_redirect off;
  9. proxy_pass http://127.0.0.1:8000;
  10. }
  11. }

Then restart your nginx process, run:

  1. nginx -s reload

4. Test

Visit http://YOUR_DOMAIN_NAME in your favorite browser.