下载好nginx包,进行解压安装。
修改 conf
文件夹下面的 nginx.conf
文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
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;
server {
listen 8090;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# location / {
# root html;
# index index.html index.htm;
# }
location /images/ {
alias /;
}
location /managePlat/ {
alias I:/html/;
}
location /manage-api/images/ {
proxy_pass http://0.0.0.0:9030/images/;
client_max_body_size 100m;
}
location /manage-api/ {
proxy_pass http://0.0.0.0:9010/;
client_max_body_size 100m;
}
#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;
}
# 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;
# }
#}
}
配置完成后,在浏览器中输入 http://0.0.0.0:9030/managePlat/index.html
就可以直接访问之前我们打包的项目了,里面的请求也可以正常请求了
这块的配置相当于我们在项目中 config
文件夹下面的 index.js
'use strict'
// Template version: 1.2.6
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/mock': {
target: 'http://0.0.0.0:2294/', // RAP地址
pathRewrite: {
'^/mock': '/mockjsdata/38' // 运营管理平台mock数据
}
},
'/manage-api/filesapi': {
target: 'http://0.0.0.0:98/', // 文件下载服务器
pathRewrite: {
'^/manage-api/filesapi': '' // 运营管理平台文件下载服务器接口前缀
}
},
'/manage-api/images': {
target: 'http://0.0.0.0:9030/images/', // 图片回显服务器地址
changeOrigin: true,
pathRewrite: {
'^/manage-api/images': '' // 图片回显接口前缀
}
},
'/manage-api': {
target: 'http://0.0.0.0:9010/', // 云服务器地址
changeOrigin: true,
pathRewrite: {
'^/manage-api': '/' // 运营管理平台接口前缀
}
},
'/api': {
target: 'http://0.0.0.0:8080/', // 请求后台本地地址
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 9926, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true,
errorOverlay: true,
notifyOnErrors: false,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-source-map', // 在cheap-source-map模式下sourcemap不包含列信息,从loaders生成的sourcemap没有被使用
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
},
}
网友评论