eggjs+vue+nginx配置
安装node
https://github.com/nodesource/distributions#installation-instructions-1
注意使用No root privileges方法安装
安装yarn
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
安装nginx
//安装nginx的命令
sudo yum install epel-release
sudo yum install nginx
//让nginx随系统启动而启动
sudo systemctl enable nginx
//常用命令
//启动:nginx
//停止:nginx -s stop
//重载配置:nginx -s reload
//配置路径:/etc/nginx/nginx.conf
//日志路径:/var/log/nginx
nginx关键配置
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name domain.com www.domain.com;
root /home/client/;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://127.0.0.1:7001/;
}
}
注意两个location和root,不要把vue的静态文件放在root目录下
注意最后一个location中,api和7001后面都有斜杠
nginx证书配置
server
{
listen 443;
server_name your-domain.com www.your-domain.com;
ssl on;
ssl_certificate /root/ssl/your-domain.crt;
ssl_certificate_key /root/ssl/your-domain.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_buffer_size 128k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
proxy_pass http://127.0.0.1:912;
}
}
server
{
listen 80;
server_name your-domain.com www.your-domain.com;
rewrite ^(.*)$ https://$host$1 permanent;
}
为了调试方便,vue.config.js的配置如下
module.exports = {
devServer: {
proxy: {
'/api': {
target:'http://127.0.0.1:7001',
changeOrigin: true,
secure: false,
pathRewrite: {
'^/api': '/' //重写之后url为 http://127.0.0.1:7001/xxxx
//pathRewrite: {'^/api': '/api'} 重写之后url为 http://192.168.1.16:8085/api/xxxx
}
}
}
}
};
egg.js调试配置如下:config文件夹下plugin.js
module.exports = {
cors: {
enable: true,
package: 'egg-cors'
}
};
config.default.js:注意这里的配置是有些危险的,因为可能会同步到服务器上去
config.security = {
csrf: {
enable: false
},
domainWhiteList: [ '*' ]
};
config.cors = {
origin: '*',
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
};
eggjs+vue+nginx配置的更多相关文章
- thinkphp5 + vue nginx配置
thinkphp5 + vue 配置 server { listen ; listen [::]:; # For https listen ssl; listen [::]: ssl; ssl_cer ...
- vue+nginx配置二级域名
[1]修改路由文件 [2]修改配置文件 [3]修改本机nginx配置文件 [4]修改服务器nginx配置文件 [5]重启nginx文件,用二级域名访问 http://192.168.199.xxx:7 ...
- 前后端分离 vue的nginx配置
nginx配置vue 有全静态化 与 vue自己的应用端口 两种方式 以下是nginx跳转到vue自己的端口 https://www.jianshu.com/p/b7bd0d352db7 以下是全静 ...
- Vue 应用 nginx 配置 前后端不分离模式
一.先在官网下载nginx 软件,解压后放在软件盘中如D盘 将nginx 文件夹拖到编译器中,打开conf 文件夹中的 nginx.conf 文件,找到其中的server {} 配置项,默认35 行. ...
- vue 子目录配置,负载均衡 nginx
1. 我使用的是,腾讯云做负载均衡. 负载均衡配置: https://www.xxxx.com/vue 域名指向的服务器地址:10.10.10.10:80/vue 2. nginx 配置: ser ...
- vue路由history模式,nginx配置
nginx配置内容 # For more information on configuration, see: # * Official English Documentation: http://n ...
- vue-router History 本地开发环境和nginx配置
vue-router mode=history本地开发环境配置 解决方法1.修改webpack的的devServer配置项(devServe存在于,rvue-cli2在webapck.config.j ...
- SpringBoot + Vue + nginx项目部署(零基础带你部署)
一.环境.工具 jdk1.8 maven spring-boot idea VSVode vue 百度网盘(vue+springboot+nginx源码): 链接:https://pan.baidu. ...
- vue-cli3.0本地代理cookie跨域请求Nginx配置
由于后端需要通过请求取前端中的cookie信息,在本地开发模式中,直接请求接口,后端无法拿到前端cookie数据, 经测试需在 vue-cli 中使用代理,如果使用Nginx做反向代理需同时修改Ngi ...
随机推荐
- vue中axios的post请求使用form表单格式发送数据
vue使用插件qs实现 (qs 是一个增加了一些安全性的查询字符串解析和序列化字符串的库.) 在jquery中的ajax的方法已将此封装,所以不需要再次序列化 1. 安装 在项目中使用命令行工具输 ...
- 【shell基础】条件测试
例1 判断目录是否存在 #!/usr/bin/bash back_dir=/var/mysql_back if ! test -d $back_dir;then mkdir -p $back_dir ...
- 二十四、SSH介绍
1.ssh介绍: SSH先对联机数据包通过加密技术进行加密处理,加密后在进行数据传输,确保了传递的数据安全.(运维的一大重视点就是要对安全敏感) 在当前的生产环境运维工作中,绝大多数企业都是SSH协议 ...
- git实用手册
git.exe clone --progress -v "git@code.sohuno.com:huimingtao/focus-wap.git" "D:\worksp ...
- ByteCode Instrumentation
Bytecode Instrumentation 定义 我们首先来看看,什么叫"Instrumentation"?Instrumentation这个词有很多意思,在维基百科中,它是 ...
- [LC] 127. Word Ladder
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest t ...
- UFT参数化
1.Resources-Record and Run Settings 2.打开程序进行录制操作 3.对Fly from和Fly to进行参数化 4.选中点击 5.输入名称,点击OK 6.在Data加 ...
- 牛客-DongDong数颜色 及其相似题
大佬博客 ps:在牛客上做到这题不会,学会之后补了两道相关题.顺便记录一下. 牛客-DongDong数颜色 sol:dfs序+莫队,先把树上的点标上dfs序,因为子树的dfs序是连续的,所以子树可以表 ...
- bootstrap 和datapicker 样式不兼容修复
修改 datepicker.js内的 layout 方法 function(el) { var options = $(el).data('datepicker'); var cal = $('#' ...
- linux下的时区修改
Centos 7时区问题: 通常使用tzselect命令选择时区,今天在修改centos7的时区的时候,修改完以后时区还是没有发生变化,重启也是没有用的:通过网络的帮助了解到,在Centos和ubun ...