1. 역방향 프록시 및 데모 환경 설명
1. 역방향 프록시
역방향 프록시는 클라이언트를 대신하여 하나 이상의 서버에서 리소스를 검색하는 프록시 서버입니다. 마치 웹 서버 자체에서 반환된 것처럼 이러한 리소스를 클라이언트에 다시 보냅니다. 연결된 클라이언트가 서버에 연결하는 중개자인 정방향 프록시와 달리 역방향 프록시는 클라이언트가 연결된 서버에 연결하는 중개자입니다.
정방향 프록시에 대한 자세한 내용은 CentOS 7 기반 Nginx 정방향 프록시 구성
2을 참조하세요. 이 데모의 여러 서버

2. 백엔드 서버 구성. (Apache)
백엔드 Apache 서버 호스트 이름 및 IP
# hostname centos7-web.example.com# more /etc/redhat-release CentOS Linux release 7.2.1511 (Core)# ip addr|grep inet|grep global inet 172.24.8.128/24 brd 172.24.8.255 scope global eno16777728# systemctl start httpd.service# echo "This is a httpd test page.">/var/www/html/index.html# curl http://localhost This is a httpd test page.
2, 프런트엔드 Nginx 역방향 프록시 서버 구성
프런트엔드 Nginx 서버 호스트 이름 및 IP
# hostname centos7-router # more /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # ip addr |grep inet|grep global inet 172.24.8.254/24 brd 172.24.8.255 scope global eno16777728 inet 192.168.1.175/24 brd 192.168.1.255 scope global dynamic eno33554960Nginx 버전
# nginx -V nginx version: nginx/1.10.2Add 새로운 구성 파일이 역방향 프록시로 사용됩니다
# vim /etc/nginx/conf.d/reverse_proxy.conf server { listen 8090; server_name localhost; location / { proxy_pass http://172.24.8.128; ###反向代理核心指令 proxy_buffers 256 4k; proxy_max_temp_file_size 0; proxy_connect_timeout 30; proxy_cache_valid 200 302 10m; proxy_cache_valid 301 1h; proxy_cache_valid any 1m; } }# systemctl reload nginx# ss -nltp|grep nginx|grep 8090LISTEN 0 128 *:8090 *:* users:(("nginx",pid=78023,fd=8),("nginx",pid=78021,fd=8))# curl http://localhost:8090 ##基于本地测试This is a httpd test page.Apache 서버 로그 보기
# more /var/log/httpd/access_log ##请求IP地址为172.24.8.254,当从其他机器请求时也是172.24.8.254这个IP172.24.8.254 - - [30/Oct/2017:14:02:38 +0800] "GET / HTTP/1.0" 200 27 "-" "curl/7.29.0"
3. 역방향 프록시 서버 및 백엔드 서버 로그 형식 설정
다음과 같이 수정된 Nginx 서버에 Proxy_set_header 지시어를 추가하세요
# grep proxy_set_header -B2 /etc/nginx/conf.d/reverse_proxy.conf location / { proxy_pass http://172.24.8.128; proxy_set_header X-Real-IP $remote_addr; }# systemctl reload nginx.service백엔드 서버 Apache 로그 형식 설정
# vim /etc/http/conf/httpd.conf# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined #注释此行,添加下一行 LogFormat "%{X-Real-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined #关键描述 {X-Real-IP}i# ip addr|grep inet|grep global #从1.132主机访问 inet 192.168.1.244/24 brd 192.168.1.255 scope global eth0# curl http://192.168.1.175:8090 #从1.244主机访问 This is a httpd test page#再次查看apache访问日志,如下,不再是代理服务器IP地址,此时显示为1.244 192.168.1.244 - - [30/Oct/2017:15:49:07 +0800] "GET / HTTP/1.0" 200 27 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh3/1.4.2"3. 역방향 프록시와 일치하는 디렉터리 백엔드 서버는 Nginx 구성을 사용합니다.
# more /etc/redhat-release ##os平台及ip地址 CentOS release 6.7 (Final)# ip addr|grep eth0|grep global inet 192.168.1.132/24 brd 192.168.1.255 scope global eth0# nginx -v ##nginx版本 nginx version: nginx/1.10.2# mkdir -pv /usr/share/nginx/html/images ##创建图片目录 mkdir: created directory `/usr/share/nginx/html/images'
# cp /usr/share/backgrounds/nature/*.jpg /usr/share/nginx/html/images/. ##复制图片文件
# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bk
# vim /etc/nginx/conf.d/default.conf ##此处直接修改缺省配置文件
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
location /images {
alias /usr/share/nginx/html/images; ##此处配置了别名
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# /etc/init.d/nginx reload
Reloading nginx: [ OK ]
프런트엔드 Nginx 구성 # vim /etc/nginx/conf.d/reverse_proxy.conf server { listen 8090; server_name localhost; location / { proxy_pass http://172.24.8.128; proxy_set_header X-Real-IP $remote_addr; } location /images { ##将images目录下的文件代理至192.168.1.132 proxy_pass http://192.168.1.132; proxy_set_header X-Real-IP $remote_addr; } }# systemctl reload nginx프록시 상황을 확인하고 이미지 디렉터리에서 jpg를 테스트합니다. IP 192.168.1.244 파일 요청
# ip addr|grep inet|grep global inet 192.168.1.244/24 brd 192.168.1.255 scope global eth0# curl -I http://192.168.1.175:8090/images/Garden.jpg HTTP/1.1 200 OK Server: nginx/1.12.2 Date: Tue, 31 Oct 2017 01:48:18 GMT Content-Type: image/jpeg Content-Length: 264831 Connection: keep-alive Last-Modified: Mon, 30 Oct 2017 08:21:28 GMT ETag: "59f6e108-40a7f" Accept-Ranges: bytes4. 특정 파일 형식에 따른 역방향 프록시 구성php 서버 측 구성(ip 192.168.1.132)
# ss -nltp|grep php LISTEN 0 128 192.168.1.132:9000 *:* users:(("php-fpm",7147,8),("php-fpm",7148,0),("php-fpm",7149,0))# mkdir -pv /data ###存放php代码# echo "/data 192.168.1.0/24(rw)" >/etc/exports# /etc/init.d/rpcbind start# /etc/init.d/nfslock start# /etc/init.d/nfs start # echo "" > /data/index.php
Nginx 에이전트 측 구성(ip 192.168.1.175)# mkdir /data# mount -t nfs 192.168.1.132:/data /data# ls /data index.php# vim /etc/nginx/conf.d/reverse_proxy.conf server { listen 8090; server_name localhost; location / { proxy_pass http://172.24.8.128; proxy_set_header X-Real-IP $remote_addr; } location /images { proxy_pass http://192.168.1.132; proxy_set_header X-Real-IP $remote_addr; } location ~ \.php$ { root /data; fastcgi_pass 192.168.1.132:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } }# systemctl restart nginxphp에 대한 역방향 프록시 테스트
[root@ydq05 ~]# ip addr|grep inet|grep global inet 192.168.1.244/24 brd 192.168.1.255 scope global eth0 [root@ydq05 ~]# curl -I http://192.168.1.175:8090/index.php HTTP/1.1 200 OK Server: nginx/1.12.2 Date: Tue, 31 Oct 2017 03:22:59 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive X-Powered-By: PHP/5.6.05. 업스트림을 기반으로 tomcat에 대한 역방향 프록시 구성 Nginx upstream 명령은 요청을 백엔드 서버에 프록시할 수도 있습니다. 다음 예는 upstream 명령과 결합되어 이를 프록시하는 방법을 보여줍니다. tomcat
# vim /etc/nginx/conf.d/tomcat.confupstream app {
server localhost:8080;
keepalive 32;
}
server {
listen 80;
server_name localhost;
location / {
proxy_set_header Host $host;
proxy_set_header x-for $remote_addr;
proxy_set_header x-server $host;
proxy_set_header x-agent $http_user_agent;
proxy_pass http://app;
}
}
[root@node132 conf.d]# ss -nltp|grep javaLISTEN 0 1 ::ffff:127.0.0.1:8005 :::* users:(("java",39559,45))
LISTEN 0 100 :::8009 :::* users:(("java",39559,43))
LISTEN 0 100 :::8080 :::* users:(("java",39559,42))
tomcat版本
[root@node132 conf.d]# /usr/local/tomcat/bin/catalina.sh versionUsing CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
....
Server version: Apache Tomcat/7.0.69
Server built: Apr 11 2016 07:57:09 UTC
Server number: 7.0.69.0
OS Name: Linux
OS Version: 2.6.32-573.el6.x86_64
Architecture: amd64
JVM Version: 1.7.0_79-b15
JVM Vendor: Oracle Corporation
验证结果# curl http://localhost
......
6. 프록시 모듈 명령 설명 프록시 모듈에 사용할 수 있는 많은 구성 지시문이 있습니다. 이는 작동 시 프록시 모듈의 많은 속성(예: 연결 시간 초과, 다음 경우에 사용되는 http 프로토콜 버전)을 정의하는 데 사용됩니다. 프록시 등 다음은 일반적으로 사용되는 명령어에 대한 간략한 설명입니다. proxy_read_timeout 연결이 끊어지기 전에 수신 업스트림 서버에서 수신된 두 읽기 작업 사이의 최대 간격 아래 예: proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 30; proxy_send_timeout 15; proxy_read_timeout 15;
위 내용은 CentOS에서 Nginx 역방향 프록시를 구성하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

NGINX는 이벤트 중심 아키텍처 및 비동기 처리 기능을 통해 성능을 향상시키고 모듈 식 설계 및 유연한 구성을 통해 확장 성을 향상 시키며 SSL/TLS 암호화 및 요청 속도 제한을 통해 보안을 향상시킵니다.

NGINX는 동시성이 높은 자원 소비 시나리오에 적합하지만 APACHE는 복잡한 구성 및 기능 확장이 필요한 시나리오에 적합합니다. 1.NGINX는 고성능과의 많은 동시 연결을 처리하는 것으로 알려져 있습니다. 2. Apache는 안정성과 풍부한 모듈 지원으로 유명합니다. 선택할 때는 특정 요구에 따라 결정해야합니다.

nginxissentialderformodernwebapplicationsduetoitsrolessareareverseproxy, loadbalancer 및 Webserver, HighperformanceAndscalability를 제공합니다

Nginx를 통해 웹 사이트 보안을 보장하려면 다음 단계가 필요합니다. 1. 기본 구성을 만들고 SSL 인증서 및 개인 키를 지정하십시오. 2. 구성 최적화, HTTP/2 및 OCSPStapling 활성화; 3. 인증서 경로 및 암호화 제품군 문제와 같은 공통 오류 디버그; 4. Let 'sencrypt 및 세션 멀티플렉싱 사용과 같은 응용 프로그램 성능 최적화 제안.

NGINX는 고성능 HTTP 및 리버스 프록시 서버로 높은 동시 연결을 처리하는 데 능숙합니다. 1) 기본 구성 : 포트를 듣고 정적 파일 서비스를 제공합니다. 2) 고급 구성 : 리버스 프록시 및로드 밸런싱을 구현하십시오. 3) 디버깅 기술 : 오류 로그를 확인하고 구성 파일을 테스트하십시오. 4) 성능 최적화 : GZIP 압축을 활성화하고 캐시 정책을 조정합니다.

Nginx 캐시는 다음 단계를 통해 웹 사이트 성능을 크게 향상시킬 수 있습니다. 1) 캐시 영역을 정의하고 캐시 경로를 설정하십시오. 2) 캐시 유효성 기간 구성; 3) 다른 컨텐츠에 따라 다른 캐시 정책을 설정합니다. 4) 캐시 저장 및로드 밸런싱을 최적화합니다. 5) 캐시 효과를 모니터링하고 디버그합니다. 이러한 방법을 통해 NGINX 캐시는 백엔드 서버 압력을 줄이고 응답 속도 및 사용자 경험을 향상시킬 수 있습니다.

dockercompose를 사용하면 Nginx의 배포 및 관리를 단순화 할 수 있으며 Dockerswarm 또는 Kubernetes를 통한 스케일링은 일반적인 관행입니다. 1) DockerCompose를 사용하여 Nginx 컨테이너를 정의하고 실행하십시오. 2) Dockerswarm 또는 Kubernetes를 통한 클러스터 관리 및 자동 스케일링 구현.

NGINX의 고급 구성은 서버 블록 및 리버스 프록시를 통해 구현 될 수 있습니다. 1. 서버 블록을 사용하면 여러 웹 사이트를 한쪽으로 실행할 수있게되면 각 블록은 독립적으로 구성됩니다. 2. 리버스 프록시는 요청을 백엔드 서버로 전달하여로드 밸런싱 및 캐시 가속도를 실현합니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.
