nginx基本配置-基于nuc980开发板的笔记

news2024/10/7 18:31:35

一、介绍

    前面的文章<nginx交叉编译移植-基于nuc980开发板的笔记>,介绍了如何移植nginx到开发板,打开的网页面是默认的网页。下面介绍如何输入网址变为指定的网页。

二、配置

①将编写的网页,放到html文件夹下,如下图:

0cdf27f4dca5c49efa5bb51007b93533.png

②打开nginx配置文件;

e0681c499a74eb4c7053c971c1f4424d.png

③进行nginx相关配置;

原配置文件:

#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;
        }


        #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;
    #    }
    #}


}

修改后的配置文件如下:

#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;
        
# 增加部分-start
gzip on;# 压缩使能,加快启动速度
      gzip_min_length 1k;
      gzip_comp_level 9;
     gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
      gzip_vary on;
      gzip_disable "MSIE [1-6]\.";


  client_max_body_size 50m;
# 增加部分-end


        location / {
            root   html;
            index  index.html index.htm;
        }
        
        # 增加部分-start
location /api {
    proxy_pass http://127.0.0.1:8000; # 后端端口
    proxy_read_timeout  3600;
    proxy_set_header x-forwarded-for  $remote_addr;
  }
  # 增加部分-end




        #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;
    #    }
    #}


}

至此,启动nginx即可。在浏览器输入地址,即可打开指定的网页,并可以进行前后端通信。

欢迎关注公众号:嵌入式学习与实践

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1213753.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

双点重发布路由策略实验

任务&IP分配如下&#xff1a; 双点重发布实验 第一步&#xff1a;配置IP地址&环回地址 以R1为例&#xff0c;R2、R3、R4同理 interface GigabitEthernet 0/0/0 ip address 12.0.0.1 24 interface GigabitEthernet 0/0/1 ip address 13.0.0.1 24 interface LookBack …

docker 安装xxl-job

1.拉取镜像 docker pull xuxueli/xxl-job-admin:2.4.0 2.docker镜像创建并运行 docker run -e PARAMS"--spring.datasource.urljdbc:mysql://xxxxx:3306/xxl_job?useUnicodetrue&characterEncodingUTF-8&autoReconnecttrue&serverTimezoneAsia/Shanghai&…

5. HTML中常用标签

5. html常用标签 5.1 标签语义 学习标签是有技巧的&#xff0c;重点是记住每个标签的语义。简单理解就是指标签的含义。即这个标签是用来干嘛的。 根据标签的语义&#xff0c;在合适的地方给一个最为合理的标签。可以让页面结构给清晰。 5.2 标题标签 <h1>-<h6>…

《算法通关村——位运算常用技巧》

《算法通关村——位运算常用技巧》 位运算的性质有很多&#xff0c;此处列举一些常见性质&#xff0c;假设以下出现的变量都是有符号整数。 ●幂等律&#xff1a;a &aa&#xff0c;a ∣ aa&#xff08;注意异或不满足幂等律&#xff09;&#xff1b; ●交换律&#xff1…

WPF xaml Command用法介绍

WPF (Windows Presentation Foundation) 中的命令设计模式是一种用于分离用户界面逻辑和业务逻辑的方法。在WPF中&#xff0c;这种模式通过命令接口&#xff08;如 ICommand&#xff09;实现&#xff0c;使得用户界面组件&#xff08;如按钮、菜单项等&#xff09;可以触发不直…

nodejs+vue电影在线预定与管理系统的设计与实现-微信小程序-安卓-python-PHP-计算机毕业设计

通过软件的需求分析已经获得了系统的基本功能需求&#xff0c;根据需求&#xff0c;将电影在线预定与管理系统功能模块主要分为管理员模块。 我国各行各业的发展在信息化浪潮的推动下也在不断进步&#xff0c;尤其是电影产业&#xff0c;在人们生活水平提高的同时&#xff0c;从…

联盟 | Quick Creator X HelpLook ,AI助力打造出海企业内容营销

随着人工智能的快速发展&#xff0c;各行各业也加快了人工智能工具的探索&#xff0c;积极将AI融入到行业发展中&#xff0c;出海外贸也不例外。AI渐渐地融入到外贸的各个环节&#xff0c;为企业出海提速增效。 为此&#xff0c;「 Quick Creator 」与 「 HelpLook 」达成战略合…

Leadshop开源商城小程序源码 – 支持公众号H5

Leadshop是一款出色的开源电商系统&#xff0c;具备轻量级、高性能的特点&#xff0c;并提供持续更新和迭代服务。该系统采用前后端分离架构&#xff08;uniappyii2.0&#xff09;&#xff0c;以实现最佳用户体验为目标。 前端部分采用了uni-app、ES6、Vue、Vuex、Vue Router、…

WordPress 媒体库文件夹管理插件 FileBird v5.5.4和谐版下载

FileBird是一款WordPress 按照文件夹管理方式的插件。 拖放界面 拖放功能现已成为现代软件和网站的标配。本机拖动事件&#xff08;包括仅在刀片中将文件移动到文件夹以及将文件夹移动到文件夹&#xff09;极大地减少了完成任务所需的点击次数。 一流设计的文件夹树展示 我们…

图解分布式事务实现原理(一)

参考 本文参考https://zhuanlan.zhihu.com/p/648556608&#xff0c;在小徐的基础上做了个人的笔记。 分布式事务场景 事务核心特性 在聊分布式事务之前&#xff0c;我们先理清楚有关于 “事务” 的定义. 事务 Transaction&#xff0c;是一段特殊的执行程序&#xff0c;其需…

STM32与ZigBee技术在智能家居无线通信中的应用研究

一、引言 智能家居系统是利用物联网技术将家庭各种设备进行互联互通&#xff0c;实现智能化控制和管理的系统。在智能家居系统中&#xff0c;无线通信技术起着至关重要的作用&#xff0c;而STM32微控制器和ZigBee技术则是实现智能家居无线通信的关键技术。本文将对STM32与ZigB…

C/C++最大质数 2021年9月电子学会青少年软件编程(C/C++)等级考试一级真题答案解析

目录 C/C比n小的最大质数 一、题目要求 1、编程实现 2、输入输出 二、算法分析 三、程序编写 四、程序说明 五、运行结果 六、考点分析 C/C比n小的最大质数 2021年9月 C/C编程等级考试一级编程题 一、题目要求 1、编程实现 对于给定的n&#xff0c;求比n小的质数中…

Spring-IoC与DI入门案例

IoC入门案例 IoC入门案例思路分析 管理什么&#xff1f;&#xff08;Service与Dao&#xff09;如何将被管理的对象告知IoC容器&#xff1f;&#xff08;配置&#xff09;被管理的对象交给IoC容器&#xff0c;如何获取到IoC容器&#xff1f;&#xff08;接口&#xff09;IoC容…

代码随想录算法训练营第五十一天|309. 买卖股票的最佳时机含冷冻期、714. 买卖股票的最佳时机含手续费

第九章 动态规划part12 309. 买卖股票的最佳时机含冷冻期 给定一个整数数组prices&#xff0c;其中第 prices[i] 表示第 i 天的股票价格 。​ 设计一个算法计算出最大利润。在满足以下约束条件下&#xff0c;你可以尽可能地完成更多的交易&#xff08;多次买卖一支股票&…

STM32 独立看门狗

目录 1.独立看门狗介绍 2.独立看门狗本质 3.独立看门狗框图​编辑 4.独立看门狗时钟 5.预分频寄存器&#xff08;IWDG_PR)​编辑 6.重装载寄存器&#xff08;IWDG_RLR) 7.键寄存器&#xff08;IWDG_KR) 8.独立看门狗实验和代码示例 9.独立看门狗和窗口看门狗的异同点 …

GB/T 1032-2023 三相异步电机试验方法 笔记

仅仅是为了技术分享。如有侵权请随时告知&#xff0c;我会尽快删除相关内容&#xff0c;谢谢&#xff01; 1.阻值的温度效应 7.x 2.温升与负载电 7.x 3.力矩修正公式及功率公式 8.3 3.1铁损和铜损测量 4.空载特性曲线 9.3 4.1 空载损耗 5.堵转特性 6.剩余损耗 6.1 另一种由转子…

自己动手实现一个深度学习算法——六、与学习相关的技巧

文章目录 1.参数的更新1&#xff09;SGD2&#xff09;Momentum3&#xff09;AdaGrad4&#xff09;Adam5&#xff09;最优化方法的比较6&#xff09;基于MNIST数据集的更新方法的比较 2.权重的初始值1&#xff09;权重初始值不能为02&#xff09;隐藏层的激活值的分布3&#xff…

基于STM32的无线通信系统设计与实现

【引言】 随着物联网的迅速发展&#xff0c;无线通信技术逐渐成为现代通信领域的关键技术之一。STM32作为一款广受欢迎的微控制器&#xff0c;具有丰富的外设资源和强大的计算能力&#xff0c;在无线通信系统设计中具有广泛的应用。本文将介绍如何基于STM32实现一个简单的无线通…

leetcode:476. 数字的补数

一、题目 476. 数字的补数 - 力扣&#xff08;LeetCode&#xff09; 函数原型&#xff1a; int findComplement(int num) 二、思路 将num的每一位取出来&#xff0c;取反后&#xff0c;乘以2的位次方&#xff0c;最终所有结果相加即可得到结果。 如何取出num的每一位&#xff1…

Unity地面交互效果目录

大家好&#xff0c;我是阿赵。   之前写了几篇关于地形交互、地面轨迹、脚印效果实现的博文。虽然写的篇数不多&#xff0c;但里面也包含了不少基础知识&#xff0c;比如局部UV采样、法线动态混合、曲面细分等知识&#xff0c;这些都是可以和别的效果组合在一起&#xff0c;做…