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

nginx 配置 本地启动

1.nginx下载地址:nginx: download

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.kler.cn/a/471264.html

相关文章:

  • Blazor用户身份验证状态详解
  • .NET AI 开发人员库 --AI Dev Gallery简单示例--问答机器人
  • 【Unity3D】Text文本文字掉落效果
  • TCP 如何获取端口信息
  • 如何在Windows上编译OpenCV4.7.0
  • 自动驾驶相关知识学习笔记
  • 移动应用安全基础:深入理解Hooking框架
  • cuda实现flash_attn_mma_share_kv源码分析
  • vue el table 不出滚动条样式显示 is_scrolling-none,如何修改?
  • Airflow:SQL Sensor 监控数据库业务变化
  • 力扣--283.移动零
  • presto权限管理
  • 计算机网络之---无线网络的传输介质
  • 使用 Flink CDC 构建 Streaming ETL
  • C++ 提升编译速度的利器:前向声明
  • 【ABAP开发环境】(三)ABAP GIT
  • 根据python代码自动生成类图的实现方法[附带python源码]
  • Python实现应用决策树的实例程序
  • model_selection.cross_val_score函数介绍
  • CES 2025:ROG打造极致游戏体验
  • python-leetcode-加油站
  • VLMs之Agent之CogAgent:《CogAgent: A Visual Language Model for GUI Agents》翻译与解读
  • 《医院项目驻场半月记:从憧憬到反思的旅程》
  • AWS re:Invent 2024 现场实录 - It‘s all about Scale
  • Mac 安装psycopg2出错:Error:pg_config executable not found的解决
  • 黄仁勋演讲总结(2种显卡,1个开源大模型,1个数据采集平台)