图片访问的是nginx 80端口
nginx 配置
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#server {
#listen 80 default_server;
#server_name _;
#return 404;
#}
# 后端 server
server {
listen 8000;
server_name 10.0.8.13;
charset utf-8;
location / {
root html/www;
include uwsgi_params;
uwsgi_pass 127.0.0.1:9000;
uwsgi_param UWSGI_SCRIPT home.wsgi;
uwsgi_param UWSGI_CHDIR /data/site/op/backend/; #项目路径
}
# Django media
location /media {
root /data/site/op/backend/media; # your Django project's media files - amend as required
}
# Django static
location /static {
root /data/site/op/backend/static; # your Django project's static files - amend as required
}
access_log /data/logs/backend.access.log;
error_log /data/logs/backend.error.log;
}
# 前端配置
server {
listen 80;
server_name 10.0.8.13;
charset utf-8;
location / {
try_files $uri $uri/ @router; #需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
root /data/site/op/ui/dist/;
add_header Cache-Control max-age=no-cache;
index index.html index.php index.htm;
}
location ~* \.(css|js|png|jpg|jpeg|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)$ {
access_log off;
add_header Cache-Control max-age=604800;
root /data/site/op/ui/dist/;
index index.html index.php index.htm;
}
location @router {
rewrite ^.*$ /index.html last;
}
access_log /data/logs/ui.access.log;
error_log /data/logs/ui.error.log;
}
}
uwsgi.ini
[uwsgi]
chdir = /data/site/op/backend
wsgi-file = /data/site/op/backend/application/wsgi.py
master = true
processes = 8
http-socket = 127.0.0.1:9000
module = application.wsgi:application
vacuum = true
log-maxsize = 20000000
log-reopen = true
buffer-size = 65536
.env.development
ENV = 'development'
VUE_APP_BASE_API = 'http://127.0.0.1:9000'
VUE_CLI_BABEL_TRANSPILE_MODULES = true
PORT=8080
是.env的配置问题 这个问题已解决 但又有了新的问题, nginx的uwsgi代理报500 , 不走nginx就可以登录, 搞了好久不知道问题在哪, 请问你有这方面的经验吗?