咖啡汪工作日志————简单的nginx 配置文件参考

2023-11-09

hello , 大家好,我是咖啡汪,又见面了!
今天给大家带来的是niginx 的简易配置文件
主要目的是让新手快速理解 nginx 配置文件中的参数与我们代码配置文件参数的对应关系,以便进行快速有效的部署

1、主前端页面访问地址8091。
2、大屏展示访问地址8098。
2、dist 文件夹位置 D:\nginx-1.18.0\cccc , vue 压缩包 dist.rar直接解压到cccc下。
3、后端地址:https://127.0.0.1:9103/
4、后端访问拼接前缀: prod-api ,前端访问全路径 http://localhost:8091/prod-api/user/information ,
对应后端访问全路径https://127.0.0.1:9103/user/information(此地址应可以直接用apipost 进行测试才是对的)。
对比下面这段代码,很容易理解对应关系

location /prod-api/ {
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass https://127.0.0.1:9103/;
			#proxy_redirect default;
			rewrite ^/api/(.*) $1 break;
			
        }

5、咖啡汪提醒切记,配置文件要在本地改好了,再上传到服务器上去,不然可能不生效!!!,nginx无法使用stop 指令完全关闭,必须用杀死进程的方式才能完全关闭!!!,然后重启就OK了。

nginx.conf 内容如下:


#user  root;
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;
	
	client_max_body_size  500m;


	client_body_timeout      5m;


	proxy_connect_timeout     75s;


	proxy_read_timeout      5m;


	proxy_send_timeout      5m;

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

#	upstream cccc{
#		server 127.0.0.1:9103 weight=1;
#		server 127.0.0.1:9104 weight=2;
#	}
	
    server {
        listen       8091;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
			root	D:/nginx-1.18.0/cccc/dist/;
            index  index.html;
			try_files $uri $uri/ /index.html;
			#@router; 
        }

		location /prod-api/ {
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass https://127.0.0.1:9103/;
			#proxy_redirect default;
			rewrite ^/api/(.*) $1 break;
			
        }
		

		
		
        #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;
        #}
    }
	server {
        listen       8098;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
			root	D:/nginx-1.18.0/cccc/bigscreen/dist/;
            index  index.html;
			try_files $uri $uri/ /index.html;
			#@router; 
        }

		location /prod-api/ {
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass https://127.0.0.1:9103/;
			#proxy_redirect default;
			rewrite ^/api/(.*) $1 break;
			
        }
		

		
		
        #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;
    #    }
    #}
	#server {
	#	listen  2211 ssl;
	#	server_name terminal.cccc-thy.com;
		
	#	ssl_certificate  ../cert/6204252_terminal.cccc-thy.com.pem;
	#	ssl_certificate_key  ../cert/6204252_terminal.cccc-thy.com.key;
		
	#	ssl_session_cache    shared:SSL:1m;
	#	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;
		
	#	rewrite ^(.*) https://$server_name$1 permanent;
	#	proxy_redirect http:// https://;
	#	location / {
		#	root html;  #站点目录。
		#	index index.html index.htm;
	#		proxy_pass http://127.0.0.1:2211/;
			#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			# 非默认端口需要添加$server_port
			#proxy_set_header Host $host:$server_port; 
			#proxy_set_header X-Real-IP $remote_addr; 
			#proxy_set_header Host $host;
			#proxy_set_header X-Forwarded-Host $http_host;
			
			#proxy_set_header X-Forwarded-Port $server_port;
	#		proxy_redirect off;

	#	}
	#}
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

咖啡汪工作日志————简单的nginx 配置文件参考 的相关文章

随机推荐

  • sql字符串拼接

    1 概述 在SQL语句中经常需要进行字符串拼接 以sqlserver oracle mysql三种数据库为例 因为这三种数据库具有代表性 sqlserver select 123 456 oracle select 123 456 from
  • Mac电脑SecureCRT安装步骤

    Securecrt Mac版是Mac os系统上一款强大易用且专业的终端SSH工具 类似于Windows中的Putty SecureCRTpo解版支持SSH1 SSH2 Telnet等远程连接 同时具有很多实用和专业的辅助功能 支持保存mi
  • 01 如何学习Python Web开发从入门到实战

    Python Web开发从入门到实战 前言 Python Web是学校所学的课程 我希望在学习的同时通过写笔记的形式来记录我学习以及由学校学习转而自身对此方向感兴趣的一个过程 更多还是让自己在课程结束之后进行一个小的总结来回顾 提高自己 当
  • C# socket服务端判断 客户端已经断开连接的一个小办法

    具体原理就是 If the remote host shuts down the Socket connection with the Shutdown method and all available data has been rece
  • C语言《数据结构》(朱战立):顺序表与链表

    数据结构 顺序表与链表 线性结构的特点是 除第一个和最后一个元素外 每个元素只有一个前驱数据元素和一个后继数据元素 线性表是一种可以在任意位置进行插入和删除数据元素操作的 由n n 0 个相同类型数据元素a0 a1 a2 an 1组成的线性
  • 区块链正在开启一场回归商业,融合商业的新发展

    对于区块链来讲 它其实同样在延续着这样一种发展路径 正如上文所说 区块链正在开启一场回归商业 融合商业的新发展 而欲要实现这一点 区块链就是要从底层算法 底层数据传输 底层体系的打造着手来实现 更为确切地说 区块链回归商业的路径 其实就是要
  • 测试技术栈整理 -- 测试开发工程师的自我修养

    导航 一 测试理论 二 单元测试 三 集成测试 四 接口测试 五 界面 UI 测试 六 性能测试 七 自动化测试 八 Linux 九 更高级别的测试 十 测试大神好文推荐 一 测试理论 标题 链接 软件的生命周期 https blog cs
  • 因果推断17--基于反事实因果推断的度小满额度模型学习笔记

    目录 一 原文地址 二 一些问题 2 1如何从RCT随机样本过渡到观测样本因果建模 2 2反事实学习的核心思想 2 3度小满的连续反事实额度模型 Mono CFR 2 4Mono CFR代码实现 待补充 2 5CFR学习 2 5 1TarN
  • 密度计算机公式,密度浓度换算公式(浓度和密度的换算关系)

    根据密度 质量除以体积 浓度 物质的量n除以体积 物质的量n等于m除以M 最后得到 密度等于物质的摩尔质量乘以密度 C 1000 d w M C 物质的量的浓度 d 密度 w 质量分数 M 摩尔质量 有多少写多少 里面好象还有升 立方米 反
  • SpringBoot 配置文件中的信息加密

    SpringBoot 配置文件敏感信息加密 说明 打开application properties或application yml 比如 MySql登陆密码 Redis登陆密码以及第三方的密钥等等一览无余 这里介绍一个加解密组件 提高一些属
  • pandas——相关系数函数corr()

    计算DataFrame列之间的相关系数 a np arange 1 10 reshape 3 3 data DataFrame a index a b c columns one two three print data one two t
  • Linux网络接口操作之if_nameindex

    系统信息 操作系统 lsb release ir Distributor ID CentOS Release 6 7 内核版本 uname r 2 6 32 573 26 1 el6 x86 64 gcc版本 gcc version gcc
  • 详解JS中的栈内存与堆内存!(配图解)

    一 栈内存 1 访问顺序 栈是一种先进后出的数据结构 栈内存是内存中用于存放临时变量的一片内存块 它是一种特殊的列表 栈内的元素只能通过列表的一端访问 这一端称为栈顶 另一端称为栈底 2 存储数据 一般来说 栈内存主要用于存储各种基本类型的
  • 【DC系列】DC-1靶场

    首先下载DC1的镜像资源 Index of downloadshttps www five86 com downloads 下载完成后进行解压 鼠标右击DC 1镜像 gt 打开方式 gt 选择虚拟机 如下图所示 输入虚拟机名称和选择虚拟机的
  • pycharm中安装并配置pyinstaller

    1 打开Anaconda Prompt 进入虚拟环境 conda activate TF1 14 2 安装pyinstaller 在anaconda中输入 pip install PyInstaller 3 在pycharm中配置pyins
  • 大数据统计分析毕业设计_大数据时代的成绩管理与数据分析毕业设计论文最新版...

    大数据时代的成绩管理与数据分析毕业设计论文 docx 由会员分享 可免费在线阅读全文 更多与 大数据时代的成绩管理与数据分析毕业设计论文 相关文档资源请在帮帮文库 www woc88 com 数亿文档库存里搜索 1 Threadslee 录
  • Lucas–Kanade光流算法学习

    转自 https www cnblogs com dverdon p 5325498 html Lucas Kanade光流算法是一种两帧差分的光流估计算法 它由Bruce D Lucas 和 Takeo Kanade提出 光流 Optic
  • CTFHub S7协议恶意攻击分析 WP

    一道分析S7Comm协议的流量题 这题经过雪姐姐的指点才得到flag 把流量包通过wireshark进行分析 使用tcp stream eq 0的指令进行一个过滤 分析0流的S7 Communication 在数据包时1321发现了stop
  • 布线问题(分支限界)

    问题描述 印刷电路板将布线区域划分成n m个方格 精确的电路布线问题要求确定连接方格a的中点到方格b的中点的最短布线方案 在布线时 电路只能沿直线或直角布线 为了避免线路相交 已布了线的方格做了封锁标记 其它线路不允穿过被封锁的方格 电路板
  • 咖啡汪工作日志————简单的nginx 配置文件参考

    hello 大家好 我是咖啡汪 又见面了 今天给大家带来的是niginx 的简易配置文件 主要目的是让新手快速理解 nginx 配置文件中的参数与我们代码配置文件参数的对应关系 以便进行快速有效的部署 1 主前端页面访问地址8091 2 大