一、本地开发必备
- nginx(本人用的是win nginx-1.16.1版本的) ;
- 配置nginx:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_header_timeout 15;
client_body_timeout 15;
send_timeout 25;
client_max_body_size 500m;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
server {
listen 80;
server_name localhost;
root html;
location /api/ {
proxy_pass http://你的后台服务ip或者域名:8680/api/;
}
location ^~ /static-web-1/ {
proxy_pass http://127.0.0.1:8082/static-web-1/;
}
location ^~ /static-web-2/ {
proxy_pass http://127.0.0.1:8081/static-web-2/;
}
location ^~ /admin-static-web/ {
proxy_pass http://127.0.0.1:8080/admin-static-web/;
}
#可以用这种方式代理本地的开发,nginx支持vue多项目代理
location / {
proxy_pass http://127.0.0.1:8080/;
}
}
}
- 配置host(C:\Windows\System32\drivers\etc)
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 ljq.imflea.com
- 全部web都使用xby.imflea.com这个域名登陆即可 ;
二、图搞懂cookie多网站共享原理
说白了就是统一一个父域名,其他的都在这个域名下代理完成即可。