安装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配置的更多相关文章

  1. thinkphp5 + vue nginx配置

    thinkphp5 + vue 配置 server { listen ; listen [::]:; # For https listen ssl; listen [::]: ssl; ssl_cer ...

  2. vue+nginx配置二级域名

    [1]修改路由文件 [2]修改配置文件 [3]修改本机nginx配置文件 [4]修改服务器nginx配置文件 [5]重启nginx文件,用二级域名访问 http://192.168.199.xxx:7 ...

  3. 前后端分离 vue的nginx配置

    nginx配置vue 有全静态化  与 vue自己的应用端口 两种方式 以下是nginx跳转到vue自己的端口 https://www.jianshu.com/p/b7bd0d352db7 以下是全静 ...

  4. Vue 应用 nginx 配置 前后端不分离模式

    一.先在官网下载nginx 软件,解压后放在软件盘中如D盘 将nginx 文件夹拖到编译器中,打开conf 文件夹中的 nginx.conf 文件,找到其中的server {} 配置项,默认35 行. ...

  5. vue 子目录配置,负载均衡 nginx

    1. 我使用的是,腾讯云做负载均衡. 负载均衡配置: https://www.xxxx.com/vue   域名指向的服务器地址:10.10.10.10:80/vue 2. nginx 配置: ser ...

  6. vue路由history模式,nginx配置

    nginx配置内容 # For more information on configuration, see: # * Official English Documentation: http://n ...

  7. vue-router History 本地开发环境和nginx配置

    vue-router mode=history本地开发环境配置 解决方法1.修改webpack的的devServer配置项(devServe存在于,rvue-cli2在webapck.config.j ...

  8. SpringBoot + Vue + nginx项目部署(零基础带你部署)

    一.环境.工具 jdk1.8 maven spring-boot idea VSVode vue 百度网盘(vue+springboot+nginx源码): 链接:https://pan.baidu. ...

  9. vue-cli3.0本地代理cookie跨域请求Nginx配置

    由于后端需要通过请求取前端中的cookie信息,在本地开发模式中,直接请求接口,后端无法拿到前端cookie数据, 经测试需在 vue-cli 中使用代理,如果使用Nginx做反向代理需同时修改Ngi ...

随机推荐

  1. java centos7 gcc编码 解决socket通信 汉字乱码

    1.把 Java eclipes 设置编码成utf-8 windows->preference->workspace 2.centos7 gcc 默认为utf-8

  2. [Usaco2009 Oct]Heat Wave 热浪(裸最短路径)

    链接:https://ac.nowcoder.com/acm/contest/1082/F来源:牛客网 题目描述 The good folks in Texas are having a heatwa ...

  3. 监控 Linux 服务器活动的几个命令(watch top ac)

    watch.top 和 ac 命令为我们监视 Linux 服务器上的活动提供了一些十分高效的途径. 为了在获取系统活动时更加轻松,Linux 系统提供了一系列相关的命令.在这篇文章中,我们就一起来看看 ...

  4. [LC] 1170. Compare Strings by Frequency of the Smallest Character

    Let's define a function f(s) over a non-empty string s, which calculates the frequency of the smalle ...

  5. mac用python读取文件常见问题(未完成)

    python读取文件常见问题(mac版) 让python的默认编码,和文件的编码保持一致

  6. Office Shared-Addin : Favorite的下载、安装和使用(2020.2.22)

    Favorite是一个可以用于Office常用组件.VBA的共用加载项,32位和64位都兼容. 如果是Office 2007及其以上版本,界面显示为Custom UI+任务窗格. 如果是Office ...

  7. [LC] 293. Flip Game

    You are playing the following Flip Game with your friend: Given a string that contains only these tw ...

  8. 98)PHP,文件类型获取和创建文件夹

    看手册  finfo这个类:This class provides an object oriented interface into the fileinfo functions. 这个$mime_ ...

  9. 分辨率与px的关系

    此篇文章的目的用于打印套打的位置计算,顺便科普下知识: 1寸=2.54厘米 14寸=355.6毫米 15.6寸=39.624厘米=396.24毫米: 21寸=533.4毫米 21.7寸=551.18毫 ...

  10. MOOC(14)- 从数据库中获取预期结果

    数据库中的预期结果写的是SQL语句 从表格中读取到SQL语句,再去数据库获取真正的预期结果 # -*- coding: utf-8 -*- # @Time : 2020/2/18 9:50 # @Fi ...