当前位置: 首页 > news >正文

nginx 配置 本地启动

1.nginx下载地址:nginx: download

    nginx详解:Nginx配置终极版指南(全网最详细)_nginx_脚本之家

2.vue 项目打包生成dist文件里面的文件复制到下载好的nginx的html目录下

3.配置nginx配置文件

打包生成的dist前端包都是属于生产环境的,打包前服务加了/api/后缀 ,axios.defaults.baseURL = process.env.NODE_ENV === 'development' ? '/api' : window.location.protocol+'//'+window.location.host + '/api';


#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       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}location /api/ {proxy_pass http://10.7.37.66:8443/;}#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;#    }#}}

4.启动nginx

5.访问localhost:80 进行登录项目,登录成功说明本地配置代理成功

http://www.lryc.cn/news/518537.html

相关文章:

  • UE5 打包要点
  • OneFlow的简单介绍
  • 聊一聊 C#异步 任务延续的三种底层玩法
  • (k8s)Flannel Error问题解决!
  • Delaunay三角刨分算法理解及c#过程实现
  • Backend - ADO.NET(C# 操作Oracle、PostgreSQL DB)
  • Idea-离线安装SonarLint插件地址
  • Leetcode Hot100 第三题 234. 回文链表
  • Python教程丨Python环境搭建 (含IDE安装)——保姆级教程!
  • SpringBoot项目实战(39)--Beetl网页HTML文件中静态图片及CSS、JS文件的引用和展示
  • ARIMA模型 (AutoRegressive Integrated Moving Average) 算法详解与PyTorch实现
  • 【Uniapp-Vue3】swiper滑块视图容器的用法
  • allure报告修改默认语言为中文
  • 国产3D CAD将逐步取代国外软件
  • GolangWeb开发- net/http模块
  • Vue2中使用Echarts
  • AI赋能服装零售:商品计划智能化,化危机为转机
  • Spring AI ectorStore
  • zig 安装,Hello World 示例
  • 龙蜥Linux系统部署docker21.1.3版本
  • django解决跨域问题
  • 【蓝桥杯选拔赛真题60】C++寻宝石 第十四届蓝桥杯青少年创意编程大赛 算法思维 C++编程选拔赛真题解
  • Git 从入门到精通
  • vue3使用vue3-video-play播放m3u8视频
  • 使用API有效率地管理Dynadot域名,为文件夹中的域名统一设置电子邮件转发
  • Java虚拟机(Java Virtual Machine,JVM)
  • [免费]微信小程序(高校就业)招聘系统(Springboot后端+Vue管理端)【论文+源码+SQL脚本】
  • TCP Analysis Flags 之 TCP Retransmission
  • #Phi-4:微软 14B 参数开源模型,性能匹敌 OpenAI GPT-4o-mini,现已登陆 Ollama
  • JSON头文件调用