个人博客

vuePress-theme-reco xiao    2020 - 2022
XIAO XIAO
Tag
时间线
GitHub (opens new window)
author-avatar

xiao

12

文章

14

标签

Tag
时间线
GitHub (opens new window)

nginx配置

vuePress-theme-reco xiao    2020 - 2022

nginx配置

xp 2019-11-21 nginx

# nginx配置

在虚拟机上下载:

  • apt-get install nginx

启动nginx:

  • service nginx start

nginx文件安装完成之后的文件位置:

  • /usr/sbin/nginx:主程序
  • /etc/nginx:存放配置文件
  • /usr/share/nginx:存放静态文件
  • /var/log/nginx:存放日志

重启nginx:

  • service nginx restart

查看nginx启动:

  • ps -ef | grep nginx

关闭nginx:

  • nginx -s stop

切换root用户:

  • su -

升级apt-get:

  • apt-get update

安装netstat:

  • netstat -tlpn 查看端口

netstat安装

安装vim:

  • apt-get install vim

# 配置文件:

server {
  	listen 80 default_server;
	listen [::]:80 default_server;
  
	server_name 172.22.200.133;

	
	location / {
		root /root/IC/dist;
   		index login.html;
		try_files $uri $uri/ @router;
	}
	
	location @router {
    		rewrite ^.*$ /index.html last;
  	}
 
   	location /api {
     		proxy_pass http://127.0.0.1:8000;# 代理接口地址
     		add_header Access-Control-Allow-Methods *;
   	}

}


解决403问题

user root


default_type    ‘text/html’;
charset utf-8;

解决vue刷新页面404 

location /v1/ {
	root /root/IC/dist/;
    index index.html;
    try_files $uri $uri/ @router;
}
 
location @router {
    rewrite ^.*$ /v1/index.html last;
}
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

解决413问题

在http{}中输入:

client_max_body_size 8M;(配置请求体缓存区大小, 不配的话)

client_body_buffer_size 128k;(设置客户端请求体最大值)

fastcgi_intercept_errors on;