NoteZ_技术博客 NoteZ_技术博客
🏠 首页
  • 📚 Web技术
  • 📋 Npm笔记
  • 📑 Markdown
  • 📄 Git笔记
  • 📝 Nginx文档
  • 📓 Linux文档
  • 📖 技术文档
  • 📜 其他文档
  • 🧊 NodeJs
  • 🎡 Express
  • 🔥 Rust
  • 🎉 Koa2
  • 🍃 MongoDB
  • 🐬 MySql
  • 🥦 Oracle
  • 🍁 Python
  • 🍄 JavaScript
  • 🌰 CSS
  • 🧄 HTML
  • 🥑 Canvas
  • 🌽 Nuxt
  • 🍆 React
  • 🥜 Vue
  • 🧅 TypeScript
  • 🌶️ AI
  • 📘 分类
  • 📗 标签
  • 📙 归档
⚜️ 在线编辑 (opens new window)
  • 📁 站点收藏
  • 📦 前端组件库
  • 📊 数据可视化
  • 🌈 开源插件
  • 🎗️ 关于我
  • 🔗 友情链接
GitHub (opens new window)

NoteZ_技术博客

前端界的小学生
🏠 首页
  • 📚 Web技术
  • 📋 Npm笔记
  • 📑 Markdown
  • 📄 Git笔记
  • 📝 Nginx文档
  • 📓 Linux文档
  • 📖 技术文档
  • 📜 其他文档
  • 🧊 NodeJs
  • 🎡 Express
  • 🔥 Rust
  • 🎉 Koa2
  • 🍃 MongoDB
  • 🐬 MySql
  • 🥦 Oracle
  • 🍁 Python
  • 🍄 JavaScript
  • 🌰 CSS
  • 🧄 HTML
  • 🥑 Canvas
  • 🌽 Nuxt
  • 🍆 React
  • 🥜 Vue
  • 🧅 TypeScript
  • 🌶️ AI
  • 📘 分类
  • 📗 标签
  • 📙 归档
⚜️ 在线编辑 (opens new window)
  • 📁 站点收藏
  • 📦 前端组件库
  • 📊 数据可视化
  • 🌈 开源插件
  • 🎗️ 关于我
  • 🔗 友情链接
GitHub (opens new window)
  • Web技术

  • Git笔记

  • Linux文档

  • Markdown

  • Nginx文档

    • Nginx 常用配置清单
    • Nginx 配置404错误页面重定向
    • Nginx 配置文件(nginx.conf)
    • Nginx二级目录反向代理网站
    • Nginx出现403跨域后端解决方法
    • Nginx访问权限控制
    • windows下安装nginx和基本配置
    • 在 Linux 下配置 Nginx 方法(启动、停止与重启)
    • 基于wujie(无界)和 Nginx 同一端口下部署多个 Vue 项目
    • 解决 Nginx 下 history 模式面刷新空白(404)问题
    • nginx配合webpack打包实现二级目录访问
    • Nginx通过二级目录映射不同的反向代理
    • Nginx配置WebSocket
    • Nginx配置维护页面
    • Nginx安装ngx_http_ssl_module模块使其支持SSL_https
  • Npm笔记

  • 技术文档

  • 其他文档

  • 前端开发
  • Nginx文档
NoteZ
2020-12-15

Nginx 配置文件(nginx.conf)

#user  nobody;
# user  root;
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;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    #gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";

    fastcgi_intercept_errors on; #开启自己的404.html页面

    server {
        listen 80;
        server_name swd.zhenglinglu.cn;
        location / {
            proxy_pass http://127.0.0.1:82;
        }
    }
    server {
        listen       80;
        #server_name  49.233.172.175;
        server_name  zhenglinglu.cn;

        underscores_in_headers on; #Nginx 转发时Header中信息不会丢失
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
      
        location / {
	        # root   zllBlog/web;
            root   /usr/local/nginx/web;
            index  index.html index.htm;
            # try_files $uri $uri/ @router; #需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
            try_files $uri $uri/ /index.html;
        }
        location /admin/ {
	        # root   zllBlog/web;
            root   /usr/local/nginx/admin;
            index  index.html index.htm;
            # try_files $uri $uri/ @router; #需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
            # try_files $uri $uri/ /index.html;
        }
        
        # location /admin/ {
        #     alias /usr/local/nginx/admin;
        #     autoindex on;
        # }
        # #根据路由设置,避免出现404
        # location ^~ /api/ {
        #         add_header 'Access-Control-Allow-Origin' '*';
        #         proxy_pass http://service.xxxx.com/;
        # }


        location /zll {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            
            proxy_pass   http://127.0.0.1:8080;
        }
        location /banner {
            proxy_pass   http://127.0.0.1:8080;
        }
       

        error_page  404 /404.html;
        location = /404.html {
            root   html;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#Nginx
上次更新: 2024/01/30, 00:35:17
Nginx 配置404错误页面重定向
Nginx二级目录反向代理网站

← Nginx 配置404错误页面重定向 Nginx二级目录反向代理网站→

最近更新
01
Gitea数据备份与还原
03-10
02
Linux 中使用 rsync 同步文件目录教程
03-10
03
Linux 使用 rsync 互相传输同步文件的简单步骤
03-08
更多文章>
Theme by Vdoing | Copyright © 2019-2025 NoteZ,All rights reserved | 冀ICP备2021027292号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式