1. location /sell/ { } # 部署自己写的项目时,记得要这样写:/sell/ ,而非 /sell ; 注意"/"
2. proxy_pass http://127.0.0.1:8900/; 结尾的“/”也要有!!!
两处的“/”问题注意。
vue版本是2.6的。(视频地址第九章9-4)
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;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name www.pickpia.com pickpia.com;
root /usr/local/myproject;
#charset koi8-r;
#access_log logs/host.access.log main;
location /blog {
rewrite ^/ https://blog.csdn.net/COCOLI_BK;
}
location /sell/ { # 部署自己写的项目时,记得要这样写:/sell/ ,而非 /sell
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8900/;
}
location /old/ {
proxy_pass http://127.0.0.1:9000/;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
#;
其中server中为关键点:
server {
listen 80;
server_name www.pickpia.com pickpia.com;
root /usr/local/myproject; // 路径到所有项目的父级目录即可,以后项目据可以放在这里咯
}