背景介绍


在部署项目时,配置Nginx端口8888,后端服务端口8088。

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

upstream base_server{ #转发至后端接口

    server localhost:8088;
    #keepalive 2000;
}

server {
    listen       8888;#前端访问端口
    server_name  localhost;
    #charset koi8-r;
    #access_log  E:/itools/nginxDir/logs/host.access.log  main;
    location / {           
        root   E:/itools/nginxDir;#前端项目放置路径
        index  index.html index.htm;
    }
    location /api/ {
        proxy_pass http://base_server/;
        proxy_set_header Host $host:$server_port;
    }

}

}

Logo

前往低代码交流专区

更多推荐