nginx 와 apache 가 함께 도망 가기 - 역방향 대리
apache 가 설 치 를 어떻게 실행 하 는 지 보고 싶 으 면 제 다른 centos 7 LAMP 설치 와 주의사항 을 볼 수 있 습 니 다.
1. apache 관련 프로필 변경 포트 번호
주 프로필:
vi /etc/httpd/conf/httpd.conf
Listen 81
가상 호스트 설정 파일:
vi /etc/httpd/conf.d/lock.com.conf
<VirtualHost 192.168.136.128:81>
DirectoryIndex index.php
ServerAdmin [email protected]
DocumentRoot /www/lockcom
ServerName lock.com
ServerAlias lock.com
<Directory /www/lockcom>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
브 라 우 저 열기
http://lock.com:81
방문 할 수 있 을 겁 니 다.
2. nginx 설치
yum 으로 설치 해 주세요.
yum nginx install
/bin/systemctl start nginx.service
systemctl status nginx.service
브 라 우 저 열기
http://lock.com
nginx 환영 페이지
3. nginx 관련 프로필 변경
nginx. conf 주 프로필:
주로 proxypass 역방향 대리
apache 가상 호스트 에 고정 IP 주 소 를 사용 했다 면 proxypass 는 같은 IP 주소 일 것 입 니 다. 설정 되 어 있 지 않 으 면 127.0.0.1 을 정상적으로 사용 하면 됩 니 다.
nginx 의 가상 호스트 설정 디 렉 터 리 를 만 들 고 홈 설정 파일 에 include / etc / nginx / vhost / *. conf 를 포함 합 니 다.
mkdir /etc/nginx/vhost
touch /etc/nginx/vhost/lock.com.conf
다음 nginx 메 인 프로필:
nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
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;
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;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
#listen 80 default_server;
#listen [::]:80 default_server;
listen 80;
server_name _;
#root /usr/share/nginx/html;
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
location / {
try_files $uri @apache;
}
location @apache {
internal;
proxy_pass http://192.168.136.128:81;
}
location ~ .*\.(php|php5)?$ {
proxy_pass http://192.168.136.128:81;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 7d;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
include /etc/nginx/vhost/*.conf;
}
가상 호스트 의 설정 vhost / lock. com. conf
vi /etc/nginx/vhost/lock.com.conf
server {
listen 80;
server_name lock.com;
access_log /www/wwwlogs/lock.com_nginx.log combined;
index index.html index.htm index.jsp index.php;
root /www/lockcom;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}
if ( $http_user_agent ~ ApacheBench|WebBench|Jmeter|must-revalidate|Havij ){
return 503;
}
location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {
valid_referers none blocked nahehuo.com *.nahehuo.com;
if ($invalid_referer) {
#rewrite ^/ http://www.lock.com/403.html;
return 403;
}
}
limit_rate 500k;
location / {
try_files $uri @apache;
}
location @apache {
internal;
proxy_pass http://192.168.136.128:81;
}
location ~ .*\.(php|php5)?$ {
proxy_pass http://192.168.136.128:81;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 7d;
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.