-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnginx.conf
53 lines (47 loc) · 2.06 KB
/
nginx.conf
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
user www-data;
worker_processes auto;
pid /run/nginx.pid;
# include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
}
http{
server {
listen 80;
server_name localhost;
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
root /etc/nginx/build; #"这里就要指定你的前端目录文件了,也就是刚刚放进nginx根目录的文件夹"
index index.htm index.html; #"build 目录下默认有index.html 指定默认文件"
try_files $uri /index.html; #"这块分重要,曾经不加尝试过,当我访问login路径时,他不会自动跳转,具体自行百度"
#error_page 405 =200 $uri;
}
location ~ /api/* {
# 这个是前端ajxa的请求地址,比如33.66.0.1:8888/api/register,都会转发给django后端,这个和开发环境还是有区别的
# 前端可以通过webpack的devserver做转发,所有后端的地址在上线时,要注意和这个设置的路由要匹配
include uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
}
#这个是你通过webpack打包后的html页面加载的文件路径
location /static {
# 指定静态文件存放的目录
root /etc/nginx/build/;
#root /home/zjp/wwwroot/dist;
#index index.html index.html;
#try_files $uri /index.html;
}
#location = / {
# proxy_pass http://172.16.179.131;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}