laravel项目的nginx和apache的反向代理配置
nginx配置laravel
参考链接 nginx配置 laravel 支持
nginx配置反向代理
server {
# 小程序认证文件
location /abc.txt {
default_type text/html;
return 200 'wenjianneirong123';
}
# 反向代理
location ~ ^/(fanxiangdaili_server)/(.*) {
set $proxy_prefix $1;
set $proxy_request_uri $2;
if ( $request_uri ~* ^/fanxiangdaili_server/(.*) ) {
set $proxy_request_uri $1;
}
proxy_pass http://127.0.0.1:8311/$proxy_request_uri;
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 $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Prefix /$proxy_prefix/;
}
}
apache配置laravel
文件名 ./conf/extra/httpd-vhosts.conf
需要依赖扩展 mod_fcgid.so
# Virtual Hosts
#
#php8.0.3
#php-cgi每个进程的最大请求数
FcgidMaxRequestsPerProcess 1000
#php-cgi最大的进程数 这个值是5代表最多可以开5个网站否则超时
FcgidMaxProcesses 5
#最大执行时间
FcgidIOTimeout 120
FcgidIdleTimeout 120
Listen 8001
<VirtualHost *:8001>
ServerName localhost
ServerAlias localhost
#单独配置php
LoadModule fcgid_module modules/mod_fcgid.so
AddHandler fcgid-script .fcgi .php
#php.ini的存放目录
FcgidInitialEnv PHPRC "${INSTALL_DIR}/bin/php/php-8.0.3"
# 设置PHP_FCGI_MAX_REQUESTS大于或等于FcgidMaxRequestsPerProcess,防止php-cgi进程在处理完所有请求前退出
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
#php-cgi的路径
FcgidWrapper "${INSTALL_DIR}/bin/php/php-8.0.3/php-cgi.exe" .php
MaxRequestLen 104857600
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews +ExecCGI
AllowOverride All
Require local
</Directory>
<Directory ~ ".*/baomi/sirendemulu.*/">
Require ip 127.0.0.1 127.0.0.2
</Directory>
# 反向代理
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "expr=%{REQUEST_SCHEME}"
RequestHeader set X-Forwarded-PREFIX "/fanxiangdaili_server"
ProxyPass /fanxiangdaili_server http://127.0.0.1:8311
ProxyPassReverse /fanxiangdaili_server http://127.0.0.1:8311
</VirtualHost>
本作品采用《CC 协议》,转载必须注明作者和本文链接