电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

Nginx是什么?

来源:金蝶云社区作者:金蝶2024-09-161

Nginx是什么?

Nginx是什么?

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器 ,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点开发的,因它的稳定性、丰富的功能集、简单的配置文件和低系统资源的消耗而闻名。

优点

  • 速度更快、并发更高

  • 配置简单,扩展性强

  • 高可靠性

  • 热部署

  • 成本低、BSD许可证

安装

下载地址:http://nginx.org/en/download.html

解压后目录如下:

img

启动

  1. 双击nginx.exe,会有黑窗闪过。

  2. 用cmd命令窗口,cd 到nginx解压目录,./nginx启动。

  3. 在浏览器中访问http://localhost:80,出现以下界面说明启动成功(由于笔者电脑80端口被占用,所以更改为8080,nginx默认为80端口)。

img

部署Vue项目

  1. 将build后的文件夹放到nginx目录下的html文件夹当中。

img

  1. 修改nginx.conf配置文件。

img

  1. 配置访问地址。

img

其他常用配置

跨域配置

img

代码:


location /api {
  proxy_set_header Host ;
  proxy_set_header X-Real-IP ;
  proxy_set_header X-Forwarded-For ;
  
  proxy_pass http://192.168.8.216:10000/api;
  proxy_redirect default;
  add_header Access-Control-Allow-Origin *;
  add_header Access-Control-Allow-Headers X-Requested-With;
  add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
  }

文件上传大小配置

img

代码:


client_max_body_size     50m;  
client_header_timeout    1m;  
client_body_timeout      1m; 
proxy_connect_timeout     60s; 
proxy_read_timeout      1m;  
proxy_send_timeout      1m;

Nginx部署Vue项目刷新404问题

img

代码:


     location / {
            root   html/dist;
            index  index.html index.htm;
            try_files   / /index.html =;
            autoindex  on;
        }

常用命令

序号命令功能
1taskkill /im nginx.exe /f关闭所有nginx进程
2tasklist | find /i “nginx.exe” || exit查看nginx的进程使用情况
3taskkill /pid 1234 /f关闭指定进程
4./nginx启动
5./nginx-s stop停止
6./nginx-s quit安全退出
7./nginx-s reload重新加载配置文件

完整配置


worker_processes  ;








events {
    worker_connections  ;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
 client_max_body_size     400m;
    client_header_timeout    5m;
    client_body_timeout      5m;
    proxy_connect_timeout     6000s;
    proxy_read_timeout      5m;
    proxy_send_timeout      5m;

    
    
    

    

    sendfile        on;
    

    
    keepalive_timeout  ;

    

    server {
        listen       ;
        server_name  .168.8.216;

        

        

        location / {
            root   html/dist;
            index  index.html index.htm;
            try_files   / /index.html =;
            autoindex  on;
        }
        
  location /api {
  proxy_set_header Host ;
  proxy_set_header X-Real-IP ;
  proxy_set_header X-Forwarded-For ;
  
  proxy_pas

Nginx是什么?

Nginx是什么?Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器 ,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信