随笔 - 502  文章 - 1 评论 - 6 阅读 - 37万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

1. 下载 打开nginx.conf

    # Windows 修改第一处
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    
    # Windows 修改第二处, 新建conf.d文件夹,用来存配置文件
    include ../conf.d/*.conf;        

 

比如vue前端项目配置

复制代码
server {
    listen       8020;
    server_name  localhost;
    
    # 静态文件地址
    root E:\xxx\folder;
    try_files $uri $uri/ /index.html;
    
    access_log logs/xxx-access.log main;
    error_log logs/xxx-error.log warn;

    location /status  {
        root html;
        stub_status on;
        access_log off;
    }
 
# 防止F5刷新404 location
/ { if (!-e $request_filename) { rewrite ^(.*)$ /index.html?s=$1 last; break; } error_page 500 502 503 504 = /50x.html; } location /stage-api/ { # 请求的后台地址 proxy_pass http://xxx.xxx.xxx.xxx:8080/; proxy_redirect off; #真实IP获取 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; set $my_proxy_add_x_forwarded_for $proxy_add_x_forwarded_for; if ($proxy_add_x_forwarded_for ~* "127.0.0.1"){ set $my_proxy_add_x_forwarded_for $remote_addr; } proxy_set_header X-Forwarded-For $my_proxy_add_x_forwarded_for; } }
复制代码

 

> nginx.exe启动

 

posted on   1161588342  阅读(7)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
历史上的今天:
2018-09-26 Netty socket.io 启用Epoll 模式异常
2018-09-26 Javac 基础
2017-09-26 Socket IO Web实时推送
点击右上角即可分享
微信分享提示