1. Nginx 基本功能配置

这篇具有很好参考价值的文章主要介绍了1. Nginx 基本功能配置。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Nginx 目录信息

图 为 windows 版本的。

1. Nginx 基本功能配置

进入Nginx的主目录我们可以看到这些文件夹

client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp

其中这几个文件夹在刚安装后是没有的,主要用来存放运行过程中的临时文件

client_body_temp fastcgi_temp proxy_temp scgi_temp

目录信息:

conf

用来存放配置文件相关 , 主要关注 nginx.conf

1. Nginx 基本功能配置

html

用来存放静态文件的默认目录 html、css等

1. Nginx 基本功能配置

sbin

nginx的主程序

logs

存放日志信息

nginx.conf 默认配置


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

}

基本运行原理

1. Nginx 基本功能配置

Nginx 配置使用

配置语法

nginx.conf 结构图可以这样概括:

main        # 全局配置,对全局生效
├── events  # 配置影响 Nginx 服务器或与用户的网络连接
├── http    # 配置代理,缓存,日志定义等绝大多数功能和第三方模块的配置
│   ├── upstream # 配置后端服务器具体地址,负载均衡配置不可或缺的部分
│   ├── server   # 配置虚拟主机的相关参数,一个 http 块中可以有多个 server 块
│   ├── server
│   │   ├── location  # server 块可以包含多个 location 块,location 指令用于匹配 uri
│   │   ├── location
│   │   └── ...
│   └── ...
└── ...

一个 Nginx 配置文件的结构就像 nginx.conf 显示的那样,配置文件的语法规则:

配置文件由指令与指令块构成;
每条指令以 ; 分号结尾,指令与参数间以空格符号分隔;
指令块以 {} 大括号将多条指令组织在一起;
include 语句允许组合多个配置文件以提升可维护性;
使用 # 符号添加注释,提高可读性;
使用 $ 符号使用变量;
部分指令的参数支持正则表达式;

Nginx 的典型配置:

user  nginx;                        # 运行用户,默认即是nginx,可以不进行设置
worker_processes  1;                # Nginx 进程数,一般设置为和 CPU 核数一样
error_log  /var/log/nginx/error.log warn;   # Nginx 的错误日志存放目录
pid        /var/run/nginx.pid;      # Nginx 服务启动时的 pid 存放位置

events {
    use epoll;     # 使用epoll的I/O模型(如果你不知道Nginx该使用哪种轮询方法,会自动选择一个最适合你操作系统的)
    worker_connections 1024;   # 每个进程允许最大并发数
}

http {   # 配置使用最频繁的部分,代理、缓存、日志定义等绝大多数功能和第三方模块的配置都在这里设置
    # 设置日志模式
    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  /var/log/nginx/access.log  main;   # Nginx访问日志存放位置

    sendfile            on;   # 开启高效传输模式
    tcp_nopush          on;   # 减少网络报文段的数量
    tcp_nodelay         on;
    keepalive_timeout   65;   # 保持连接的时间,也叫超时时间,单位秒
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;      # 文件扩展名与类型映射表
    default_type        application/octet-stream;   # 默认文件类型

    include /etc/nginx/conf.d/*.conf;   # 加载子配置项
    
    server {
    	listen       80;       # 配置监听的端口
    	server_name  localhost;    # 配置的域名
    	
    	location / {
    		root   /usr/share/nginx/html;  # 网站根目录
    		index  index.html index.htm;   # 默认首页文件
    		deny 172.168.22.11;   # 禁止访问的ip地址,可以为all
    		allow 172.168.33.44; # 允许访问的ip地址,可以为all
    	}
    	
    	error_page 500 502 503 504 /50x.html;  # 默认50x对应的访问页面
    	error_page 400 404 error.html;   # 同上
    }
}

1. Nginx 基本功能配置

参考链接: https://www.nginx.org.cn/article/detail/545

html 404 配置

html 目录下 默认有 index.html 和 50x.html 页面

输入网址: http://localhost/

1. Nginx 基本功能配置

添加 404 页面

输入一个不存在的网址: http://localhost/yjl.html

1. Nginx 基本功能配置

1. Nginx 基本功能配置

将 #error_page 404 /404.html; 放开 , 并且在 html 页面 编写一个 404.html 信息

1. Nginx 基本功能配置

再访问网址: http://localhost/yjl.html

1. Nginx 基本功能配置

404 跳转到 50x.html

1. Nginx 基本功能配置

1. Nginx 基本功能配置

404 跳转到首页

  location / {
            root   html;
            index  index.html index.htm;
			# 试图访问某个文件, 如果在 就使用原文件,如果不在,就用  /index.html
			try_files $uri $uri/ /index.html;
        }

再访问网址: http://localhost/yjl.html , 跳转到 index.html 页面

1. Nginx 基本功能配置

html 页面配置

往 html 页面里面放置一个 js 项目 Stock_Page, 那么访问时可以:

1. Nginx 基本功能配置

http://localhost/Stock_Page/page.html

1. Nginx 基本功能配置

root 配置静态资源

上面是将 Stock_Page 项目放置在 html 目录下, 实际应用中,一般都是将 项目 单独放置, 不放置在 html 下。 进行动态的配置。

Stock_Page 放置在 目录 : C:\Users\20481\Downloads\nginx-1.22.1
1. Nginx 基本功能配置

    	location /Stock_Page {
			root C:\\Users\\20481\\Downloads\\nginx-1.22.1;
			index page.html page.htm;
		}
        location / {
            root   html;
            index  index.html index.htm;
			# 试图访问某个文件, 如果在 就使用原文件,如果不在,就用  /index.html
			try_files $uri $uri/ /index.html;
        }

输入 网址 : http://localhost/Stock_Page/page.html 可以查看页面

使用 root 时, 是 location /访问地址 , 对应的 就是 文件夹名, 这两个要一一对应。

alias 配置静态资源

location /Stock_Page {
			root C:\\Users\\20481\\Downloads\\nginx-1.22.1;
			index page.html page.htm;
		}
		location /Stock {
			alias C:\\Users\\20481\\Downloads\\nginx-1.22.1\\Stock_Page;
			index page.html page.htm;
		}
        location / {
            root   html;
            index  index.html index.htm;
			# 试图访问某个文件, 如果在 就使用原文件,如果不在,就用  /index.html
			try_files $uri $uri/ /index.html;
        }

使用 alias 时 , location /网址 只是一个引入, alias 会找真实的地址路径。

http://localhost/Stock/page.html

即可以访问信息。

root 和 alias 的区别:

root用来设置根目录,而alias在接受请求的时候在路径上不会加上location

1)alias指定的目录是准确的,即location匹配访问的path目录下的文件直接是在alias目录下查找的;
2)root指定 的目录是location匹配访问的path目录的上一级目录,这个path目录一定要是真实存在root指定目录下的;
3)使用 alias标签的目录块中不能使用rewrite的break(具体原因不明);
另外,alias指定的目录后面必须要加上"/“符 号!!
4)alias虚拟目录配置中,location匹配的path目录如果后面不带”/“,
那么访问的url地址中这个path目录后 面加不加”/“不影响访问,访问时它会自动加上”/“;
但是如果location匹配的path目录后面加上”/“,那么访问的url地 址中这个path目录必须要加上”/“,
访问时它不会自动加上”/“。如果不加上”/“,访问就会失败!
5)root目录配置 中,location匹配的path目录后面带不带”/",都不会影响访问。

配置静态资源

location ~ ^/(images|js|css|flash|media|static)/ {
    root C:\\Users\\20481\\Downloads\\nginx-1.22.1\\staticFile;
    #过期30天,静态文件不怎么更新,过期可以设大一点,如果频繁更新,则可以设置得小一点。
    expires 30d;
}

配置动态反向代理

location /StockApi {
    # 把 /stock 路径下的请求转发给真正的后端服务器
    rewrite  ^/(.*)$ /$1 break;
    proxy_pass http://127.0.0.1:8088$request_uri;
    fastcgi_buffers 8 128k;
    send_timeout 60;
    client_max_body_size     100m;
}

这样,访问 /StockApi/user/1 /StockApi/stock/002415
就可以访问到对应的后端接口请求信息。

location 配置规则

使用一个location 使用正则 location 前缀
/ 通用匹配,任何请求都会匹配到。
= 精准匹配,不是以指定模式开头
~ 正则匹配,区分大小写
~* 正则匹配,不区分大小写
^~ 非正则匹配,匹配以指定模式开头的location

location匹配顺序:

多个正则location直接按书写顺序匹配,成功后就不会继续往后面匹配

普通(非正则)location会一直往下,直到找到匹配度最高的(最大前缀匹配)

当普通location与正则location同时存在,如果正则匹配成功,则不会再执行普通匹配

所有类型location存在时,“=”匹配 > “^~”匹配 > 正则匹配 > 普通(最大前缀匹配)

配置负载均衡

	upstream myproxy{
		server localhost:8088;
		server 127.0.0.1:8088; 	 
	}
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;


		location /StockApi {
			# 把 /stock 路径下的请求转发给真正的后端服务器
			rewrite  ^/(.*)$ /$1 break;
			proxy_pass http://myproxy$request_uri;
			fastcgi_buffers 8 128k;
			send_timeout 60;
			client_max_body_size     100m;
		}
}

负载均衡配置权重

	upstream myproxy{
		server localhost:8088 weight = 10 down;
		server 127.0.0.1:8088 weight = 1; 	
		server 192.168.100.54:8088 weight = backup; 			
	}

down:表示当前的server暂时不参与负载

weight:默认为1.weight越大,负载的权重就越大。

backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。

upstream myproxy{
		server localhost:8088 weight = 10 down;
		server 127.0.0.1:8088 weight = 10 max_fails=5 fail_timeout=10s; 	
		server 127.0.0.1:8088 weight = 10 max_fails=5 fail_timeout=10s; 	
		server 192.168.100.54:8088 weight = backup; 			
	}

参考链接: https://blog.csdn.net/LL845876425/article/details/97621365

rewrite 使用

rewrite语法格式及参数语法:

rewrite是实现URL重写的关键指令,根据regex (正则表达式)部分内容, 重定向到replacement,结尾是flag标记。

rewrite [flag];

关键字 正则 替代内容 flag标记

关键字:其中关键字error_log不能改变

正则:perl兼容正则表达式语句进行规则匹配

替代内容:将正则匹配的内容替换成replacement

flag标记:rewrite支持的flag标记

rewrite参数的标签段位置:

server,location,if

flag标记说明:

last #本条规则匹配完成后,继续向下匹配新的location URI规则
break #本条规则匹配完成即终止,不再匹配后面的任何规则
redirect #返回302临时重定向,浏览器地址会显示跳转后的URL地址
permanent #返回301永久重定向,浏览器地址栏会显示跳转后的URL地址

实例

rewrite ^/([0-9]+).html$  /index.jsp?pageNum=$1 break;

$1 表示正则匹配符合的 第一个值。

如 请求信息匹配, 后端接口请求:

  location /StockApi {
                # 把 /stock 路径下的请求转发给真正的后端服务器
                rewrite  ^/(.*)$ /$1 break;
                proxy_pass http://127.0.0.1:8088$request_uri;
                fastcgi_buffers 8 128k;
                send_timeout 60;
                client_max_body_size     100m;
        }

/StockApi 后面所有的信息, 当成一个参数 /$1

参考链接: https://blog.csdn.net/LL845876425/article/details/100999186

1. Nginx 基本功能配置

1. Nginx 基本功能配置

域名跳转

1. Nginx 基本功能配置

rewrite ^/(.*) http://www.yueshushu.top/$1 permanent;


rewrite ^/(.*) http://www.yueshushu.top/$1 redirect;

post 请求方法跳转

1. Nginx 基本功能配置

return 307 http://www.yueshushu.top/$request_uri;

return 308 http://www.yueshushu.top/$request_uri;

try_files 匹配规则

寻找某个路径, 如果存在,则使用原路径, 如果不存在,则使用新的路径。

如 html 404 配置中, 如果路径不存在,则跳转到首页

 try_files $uri $uri/ /index.html;

如果不存在,则 找默认的图片

 try_files $uri   $uri/  /images/logo.jpg; 

配置 html 带不带均可以访问

如访问路径 , 有一个路径 /dev/md5.html, 希望访问 /dev/md5 可以请求到, /dev/md5.html 也可以请求到

可以这么配置

try_files $uri $uri/ $uri.html u r i . p h p uri.php uri.phpis_args$query_string;

location /dev {
        try_files $uri $uri/ $uri.html $uri.php$is_args$query_string;
        root /etc/nginx;
            index index.html index.htm;
        }

防盗链配置

访问 : https://www.yueshushu.top/logo.jpg

1. Nginx 基本功能配置

请求头不携带任何信息都可以访问

valid_referers none | blocked | server_names | strings …;

none, 检测 Referer 头域不存在的情况。
blocked,检测 Referer 头域的值被防火墙或者代理服务器删除或伪装的情况。这种情况该头域的值不以 “http://” 或 “https://” 开头。
server_names ,设置一个或多个 URL ,检测 Referer 头域的值是否是这些 URL 中的某一个。

            	valid_referers *.yueshushu.top www.yueshushu.top *.baidu.com *.google.com;
                if ($invalid_referer) {
                        return 403;
                }

只允许 这几个访问: *.yueshushu.top www.yueshushu.top *.baidu.com *.google.com;

注意, Referer 时, 请求值 要加上协议。

location / {
                root html;
                index  index.html index.htm;
                valid_referers *.yueshushu.top www.yueshushu.top *.baidu.com *.google.com;
                if ($invalid_referer) {
                        return 403;
                }
                try_files $uri $uri/ /index.html;
        }

再次请求时:

1. Nginx 基本功能配置

1. Nginx 基本功能配置

配置 https 443 端口访问

免费申请一个证书, 下载 nginx 版本的

1. Nginx 基本功能配置

使用到 域名.key 域名_bundle.crt 两个证书

上传到 /etc/nginx/ssl/Nginx 目录下

1. Nginx 基本功能配置

进行配置:

	server {
		listen       443 ssl;
		server_name  www.yueshushu.top;
		ssl_certificate   /etc/nginx/ssl/Nginx/1_www.yueshushu.top_bundle.crt;
		ssl_certificate_key  /etc/nginx/ssl/Nginx/2_www.yueshushu.top.key;

    	# 其它的配置信息
}

如此即可.

配置 https 和 http 均可以访问

访问 http 时,会跳转到 https 协议地址

# 将Http请求转化成Https请求
server {
  listen 80;
  server_name www.yueshushu.top;
  rewrite ^/(.*) https://$server_name$request_uri? permanent;
}

配置多个虚拟服务器

在实际业务中, 常常 有多个 前端项目, 每个项目可能存在多个分支, 可这些分支拥有着相同的请求路径, 如 都是 /StockApi , 这个时候,在同一个 server 下配置就不好了。 更不应该 复制多个 nginx ,每一个 nginx 跑一个项目。

实际上,对 单个 nginx 可以配置多个虚拟服务器, 拥有着不同的端口号, 这样就可以给不同的项目使用了。

端口号 listen 和 前端 路径 不同 alias

server {
		listen       8027;
		server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;


		location /StockApi {
			# 把 /stock 路径下的请求转发给真正的后端服务器
			rewrite  ^/(.*)$ /$1 break;
			proxy_pass http://myproxy$request_uri;
			fastcgi_buffers 8 128k;
			send_timeout 60;
			client_max_body_size     100m;
		}

		location ~ ^/(images|js|css|flash|media|static)/ {
			root C:\\Users\\20481\\Downloads\\nginx-1.22.1\\staticFile;
			#过期30天,静态文件不怎么更新,过期可以设大一点,如果频繁更新,则可以设置得小一点。
			expires 30d;
		}
		location /Stock {
			alias C:\\Users\\20481\\Downloads\\nginx-1.22.1\\Stock_Page;
			index page.html page.htm;
		}
        location / {
            root   html;
            index  index.html index.htm;
			# 试图访问某个文件, 如果在 就使用原文件,如果不在,就用  /index.html
			try_files $uri $uri/ /index.html;
        }
    }
	
	server {
		listen       8081;
		server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;


		location /StockApi {
			# 把 /stock 路径下的请求转发给真正的后端服务器
			rewrite  ^/(.*)$ /$1 break;
			proxy_pass http://myproxy$request_uri;
			fastcgi_buffers 8 128k;
			send_timeout 60;
			client_max_body_size     100m;
		}

		location ~ ^/(images|js|css|flash|media|static)/ {
			root C:\\Users\\20481\\Downloads\\nginx-1.22.1\\staticFile;
			#过期30天,静态文件不怎么更新,过期可以设大一点,如果频繁更新,则可以设置得小一点。
			expires 30d;
		}
		location /Stock {
			alias C:\\Users\\20481\\Downloads\\nginx-1.22.1\\CainiaoStock_Page;
			index page.html page.htm;
		}
        location / {
            root   html;
            index  index.html index.htm;
			# 试图访问某个文件, 如果在 就使用原文件,如果不在,就用  /index.html
			try_files $uri $uri/ /index.html;
        }
    }
	server {
		listen       8082;
		server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;


		location /StockApi {
			# 把 /stock 路径下的请求转发给真正的后端服务器
			rewrite  ^/(.*)$ /$1 break;
			proxy_pass http://myproxy$request_uri;
			fastcgi_buffers 8 128k;
			send_timeout 60;
			client_max_body_size     100m;
		}

		location ~ ^/(images|js|css|flash|media|static)/ {
			root C:\\Users\\20481\\Downloads\\nginx-1.22.1\\staticFile;
			#过期30天,静态文件不怎么更新,过期可以设大一点,如果频繁更新,则可以设置得小一点。
			expires 30d;
		}
		location /Stock {
			alias C:\\Users\\20481\\Downloads\\nginx-1.22.1\\yjlStock_Page;
			index page.html page.htm;
		}
        location / {
            root   html;
            index  index.html index.htm;
			# 试图访问某个文件, 如果在 就使用原文件,如果不在,就用  /index.html
			try_files $uri $uri/ /index.html;
        }
    }

servername匹配规则 我们需要注意的是servername匹配分先后顺序,
写在前面的匹配上就不会继续往下匹配了。

完整匹配 我们可以在同一servername中匹配多个域名 server_name vod.mmban.com www1.mmban.com;

通配符匹配 server_name *.mmban.com

通配符结束匹配 server_name vod.*;

正则匹配 server_name ~1+.mmban.com$;

跨域 cors 配置

在浏览器上当前访问的网站向另一个网站发送请求获取数据的过程就是跨域请求。

跨域是浏览器的同源策略决定的,是一个重要的浏览器安全策略,用于限制一个 origin 的文档或者它加载的脚本与另一个源的资源进行交互,它能够帮助阻隔恶意文档,减少可能被攻击的媒介,可以使用 CORS 配置解除这个限制。

关于跨域网上已经有很多解释,这里就不啰嗦,也可以直接看 MDN 的 <浏览器的同源策略> 文档进一步了解,这里就列举几个同源和不同元的例子,相信程序员都能看得懂。

# 同源的例子
http://example.com/app1/index.html  # 只是路径不同
http://example.com/app2/index.html

http://Example.com:80  # 只是大小写差异
http://example.com

# 不同源的例子
http://example.com/app1   # 协议不同
https://example.com/app2

http://example.com        # host 不同
http://www.example.com
http://myapp.example.com

http://example.com        # 端口不同
http://example.com:8080

配置跨域:

	server {
		listen       8027;
		server_name  localhost;


	  #允许跨域请求的域,* 代表所有
      add_header 'Access-Control-Allow-Origin' *;
      #允许带上cookie请求
      add_header 'Access-Control-Allow-Credentials' 'true';
      #允许请求的方法,比如 GET/POST/PUT/DELETE
      add_header 'Access-Control-Allow-Methods' *;
      #允许请求的header
      add_header 'Access-Control-Allow-Headers' *;

      # 省略配置 location 

}

参考链接: https://blog.csdn.net/qq_38011415/article/details/107095403

配置 真实的 IP 和端口

nginx 转发之后,后端获取的 IP地址等信息,是 nginx 所在服务器的 IP地址, 并不是 客户请求时的 IP地址。

    		proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Real-PORT $remote_port;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

在具体的 location 下

	location /StockApi {
			# 把 /stock 路径下的请求转发给真正的后端服务器
			proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Real-PORT $remote_port;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

			rewrite  ^/(.*)$ /$1 break;
			proxy_pass http://myproxy$request_uri;
			fastcgi_buffers 8 128k;
			send_timeout 60;
			client_max_body_size     100m;
		}

配置成功。

配置开启 gzip

gzip on; # 默认off,是否开启gzip
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

# 上面两个开启基本就能跑起了,下面的愿意折腾就了解一下
gzip_static on;
gzip_proxied any;
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
# gzip_min_length 1k;
gzip_http_version 1.1;

1. Nginx 基本功能配置


  1. 0-9 ↩︎文章来源地址https://www.toymoban.com/news/detail-448932.html

到了这里,关于1. Nginx 基本功能配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Linux下基本指令 -> ls指令 查看目录结构和文件信息

    ​  博主: 星尘不会落  博主主页:https://blog.csdn.net/zhanghgh  如果编写的博客中有任何错误,请指出,我会第一时间核实并更改。  该博客可能会随着博主的技术增进而改进。  Linux ls(英文全拼: list directory contents )命令用于显示指定工作目录下之内容(列出目前工作

    2024年02月07日
    浏览(39)
  • React + 二级目录 + Nginx配置

    背景: 由于子域名有限,我们需要将不同的前端项目进行二级目录区分。 一、项目 现有三个项目: bsrm-web-manage bsrm-web-operator bsrm-web-testingorganization 二、期望访问路径 http://bsrm.life.com/bsrm-web-manage http://bsrm.life.com/bsrm-web-operator http://bsrm.life.com/bsrm-web-testingorganization 三、React 配

    2024年02月15日
    浏览(32)
  • nginx简介与安装配置,目录结构和配置文件介绍,配置nginx的service管理

    目录 一.nginx简介 1.简介 2.特性 二.nginx安装 1.rpm包方式 (1)下载扩展源 (2)安装扩展rpm包,nginx -V查看配置参数,后面源码安装时要用到 (3)默认的配置文件位置和html存放位置 2.源码方式 (1)建议提前下好所需要的部分包 (2)下载tar.gz包 (3)建议将包解压到/usr/local

    2024年02月04日
    浏览(33)
  • Nginx - 目录结构与配置文件详解

    目录 conf nginx.conf  worker_processes worker_connections include mime.types; default_type application/octet-stream; sendfile sendfile off;  sendfile on; keepalive_timeout  65; server {} location / {} error_page   500 502 503 504  /50x.html; html index.html 50x.html logs access.log error.log nginx.pid  sbin Nginx  Nginx的目录结构: 这里方便直

    2024年02月07日
    浏览(37)
  • 【web渗透思路】框架敏感信息泄露(特点、目录、配置)

      博主:网络安全领域狂热爱好者(承诺在CSDN永久无偿分享文章)。 殊荣:CSDN网络安全领域优质创作者,2022年双十一业务安全保卫战-某厂第一名,某厂特邀数字业务安全研究员,edusrc高白帽,vulfocus、攻防世界等平台排名100+、高校漏洞证书、cnvd原创漏洞证书等。 擅长:对

    2023年04月19日
    浏览(37)
  • Nginx使用 代理转发Windows远程桌面RDP功能

    一、业务需求 B是服务器192.168.31.200,A电脑192.168.31.100是跳板机,只有A这台电脑可以远程桌面访问B服务器。现在需要通过一台远程这台跳板机,间接实现对服务器B的远程访问。 二、配置nginx 在A电脑上安装Nginx,配置文件添加如下配置项: 注意:如果有多个stream模块需要设置

    2024年02月15日
    浏览(53)
  • Php+Nginx项目配置信息配置到环境变量

    通过nginx,配置到nginx.conf里面 fastcgi_param key “value”; 在php中通过 $_SERVER[\\\"key\\\"] 即可读取

    2024年02月05日
    浏览(35)
  • nginx vue2+webpack 和 vue3+vite 配置二级目录访问

    我们开发中会遇到这样的需求,让我们用服务器nginx部署一个用域名的二级目录来访问项目 https:xxx/二级目录/ 来放访问项目 目录 思路 1、nginx配置(vue2 和 vue3配置的nginx相同) 2、vue2+webpack的配置 (1)vue.config.js配置 (2)router配置 3、vue3+vite的配置 (1)vite.config.js配置 (

    2024年02月09日
    浏览(47)
  • 工业安全生产信息化平台的基本架构和关键功能分享

    工业安全生产信息化平台是指利用信息技术手段,将工业安全生产管理与数据采集、传输、处理相结合,实现对工业安全生产全过程的数字化、信息化、智能化管理的平台。它通过集成多种信息系统和设备,实现对重大危险源监控预警、安全风险分级管控、安全生产一张图等

    2024年02月11日
    浏览(34)
  • Nginx基本配置

    本教程讲述Nginx的基本配置和操作。首先需要安装 Nginx,关关于具体的安装方式,可以参见Nginx简介与安装一文。为了方便,这里基于CentOS 7的官方Docker镜像来说明,你也可以使用你熟悉的任意Linux发行版。 使用的Dockerfile如下: 构建镜像: 交互式运行镜像: 这里便进入到了一

    2024年02月01日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包