您的位置:首页 > 文旅 > 美景 > 国家商标查询官网入口_网线接线顺序_就业seo好还是sem_公司网络推广

国家商标查询官网入口_网线接线顺序_就业seo好还是sem_公司网络推广

2025/2/6 7:46:07 来源:https://blog.csdn.net/mgwzz/article/details/145060774  浏览:    关键词:国家商标查询官网入口_网线接线顺序_就业seo好还是sem_公司网络推广
国家商标查询官网入口_网线接线顺序_就业seo好还是sem_公司网络推广

实验1:基本实现

yum install nginx -y
systemctl start nginx.service

systemctl restart nginx.service

vim /etc/nginx/nginx.conf  修改配置文件

把 root 的路径改为 /var/www/html

echo "hello world" > /var/www/html/index.html   

重启服务

[root@server ~]# curl 192.168.245.128
hello world

 

注意:所有实验中配置更改后都要重启nginx

 实验2:一般实现:修改端口、默认目录、默认文件访问web页面

1. 通过不同的端口访问同一web页面 

在/etc/nginx/conf.d下创建新的文件-- ip.conf
配置如下
server { listen 192.168.245.128:888; location / { root /web/html;} 
} 
如果root在location里面,那么会覆盖server模块里的root

保存后重启服务

 2. 通过不同的默认目录访问同一web页面

 实际就是实验一。因为如果是刚开始的文件,那么显示的应该是linux那个页面

3. 通过不同的文件访问web页面 

mkdir /web/haha

echo "i am haha " > /web/haha/index.html

root /web;  (还是上面那个配置文件,改个路径)

实验3:虚拟主机:基于不同端口、不同目录、不同IP、不同域名访问不同页面 

1. 基于不同端口访问不同页面

server { listen 192.168.245.128:122; location / { root /web/122;} 
} 
server { listen 192.168.245.128:132; location / { root /web/132;} 
} 

2. 基于不同目录访问不同页面

 。。。 感觉和2.3一样

3. 基于不同IP访问不同页面 

nmcli connection modify ens160 +ipv4.addresses 192.168.245.123/24
nmcli connection up ens160
mkdir /web/{123,132}
echo my ip is 123 > /web/123/index.html
echo my ip is 132 > /web/132/index.html
vim /etc/nginx/conf.d/ip.conf
server {
listen 192 .168.245.128:80;
root /web/132;
location / {
index index.html;
}
}
server {
listen 192 .168.245.123:80;
root /web/123;
location / {
index index.html;
}
}

4.基于不同域名访问不同页面 

server {
listen 192.168.245.128:80;
server_name www.xixi132.com;
location / {
root /web/132;
}
}
server {
listen 192.168.245.128:80;
server_name www.haha123.com;
location / {
root /web/123;
}
}

 vim /etc/hosts

实验4:访问控制

1. 基于不同用户的访问控制 

htpasswd -cb /etc/nginx/conf.d/auth_passwd li4 123
htpasswd -cb /etc/nginx/conf.d/auth_passwd2 tom 123
server {
listen 192.168.245.128:80;
location / {
root /web/132;
auth_basic on;   
auth_basic_user_file /etc/nginx/conf.d/auth_passwd;
}
}
server {
listen 192.168.245.123:80;
location / {
root /web/123;
auth_basic on;   
auth_basic_user_file /etc/nginx/conf.d/auth_passwd;
}
}

 2. 基于源ip的访问控制

server {
listen 80;
location / {
root /web/132;
allow 192.168.245.123/24;
deny 192.168.245.128/24;
}
}

实验5:证书

cd /etc/pki/tls/certs/
openssl genrsa -out miyao.key
openssl req -utf8 -new -key /etc/pki/tls/certs/miyao.key -x509 -days 100 -out /zhengshu.crt
server {
listen 192.168.245.128:443 ssl;
location / {
root /web/132;
}
ssl_certificate "/zhengshu.crt";
ssl_certificate_key "/etc/pki/tls/certs/miyao.key";
}

实验6nginx发布动态页面的方法 

yum install php php-fpm -y
echo "<?php phpinfo(); ?>" > /web/php/index.php

server {
listen 80;
location / {
root /web/php;
include /etc/nginx/default.d/php.conf;
}
}

selinux

1. 在enforing 模式下,nginx的端口号被修改,并是实现页面正常访问

要想访问的时候不是403,那么就要修改nginx中root 目录的安全上下文

[root@server ~]# ls -Zd /web/132

unconfined_u:object_r:default_t:s0 /web/132

[root@server ~]# ls -Zd /usr/share/nginx/html/

system_u:object_r:httpd_sys_content_t:s0 /usr/share/nginx/html/

[root@server ~]# chcon -Rv -t httpd_sys_content_t /web/132

正在更改 '/web/132/index.html' 的安全上下文

正在更改 '/web/132/index.php' 的安全上下文

正在更改 '/web/132' 的安全上下文

[root@server ~]# ls -Zd /web/132

unconfined_u:object_r:httpd_sys_content_t:s0 /web/132

查看selinux允许的端口号
semanage port -l | grep http_port_t
使用semanage命令将777端口号添加到http_port_t类型列表中
semanage port -a -t http_port_t -p tcp 777
server {
listen 777;
location / {
root /web/132;
}
}

2. enforing 模式下,演示ssh端口号修改的selinux设定


vim /etc/ssh/sshd_config # 修改ssh的端口号为33
semanage port -a -t ssh_port_t -p tcp 2222 # 添加33端口

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com