修改本地host文件,映射到域名
C:\Windows\System32\drivers\etc
添加
127.0.0.1 weixinkaifa.com
Nginx 做代理,把80端口转发到您本地应用地址
#user nobody;
worker_processes 1;
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;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
#关键设置:将80端口转发到 8099 端口 ,下面是你项目的开发环境访问地址!!!!
proxy_pass http://127.0.0.1:8089;
}
}
}
通过域名访问项目
启动项目,访问:
http://www.weixinkaifa.com/
此时,访问通过代理 访问顺序
http://www.weixinkaifa.com > 120.0.0.1:8099