[Java2023] Day10(03)-前后端联调

24 阅读1分钟
  • 注意, 这里使用教程准备的Nginx, 它里面设置好了Nginx 反向代理,端口等, 连前端文件都放在里面
  • 将本低的nginx先暂停, 用他这个即可,java的程序启动, 会代理到java的8080端口

image.png

worker_processes  1;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       90;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

        location ^~ /api/ {
			rewrite ^/api/(.*)$ /$1 break;
			proxy_pass http://localhost:8080;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

image.png