具体需求就是在当前域名下的/doc/
地址映射到其他vue项目
以下是nginx.conf配置文件
server {
listen 80;#监听端口
server_name localhost;#域名
index index.html index.htm index.php;
root nginx/html;#站点目录
location / {
root html/monitor;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /doc/ {
proxy_pass localhost:81;
}
location ~* \.(gif|jpg|jpeg|png|css|js|ico|css|eot|svg|ttf|woff|mov)$ {
root html/monitor;
expires 48h;
access_log off;
}
location ~ .*\.(php|php5)?$ {
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
expires 30d;
# access_log off;
}
location ~ .*\.(js|css)?$ {
expires 15d;
# access_log off;
}
}
server {
listen 81;#监听端口
server_name localhost;#域名
index index.html index.htm index.php;
root nginx/html;#站点目录
location / {
root html/doc/doc;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location ~* .*\.(gif|jpg|jpeg|png|css|js|ico|css|eot|svg|ttf|woff|mov)$ {
root html/doc-public/doc;
expires 48h;
access_log off;
}
location ~ .*\.(php|php5)?$ {
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
expires 30d;
# access_log off;
}
location ~ .*\.(js|css)?$ {
expires 15d;
# access_log off;
}
access_log off;
}
遇到的问题:
然后映射的xxx.com/doc
目录下,css和js文件加载不出来,请教一下各位大神如何解决。
已经尝试过location 的alias和root映射对应项目文件夹,也不行。
尝试过修改location ~ ^/doc/.*\.(js|css)?$*
映射样式文件,也不行。
proxy_pass http://localhost:8000/uri/;
这个才是正确格式http://nginx.org/en/docs/http...