apache-proxy-配置反向代理.conf
<VirtualHost *:80> DocumentRoot "/www/admin/www.ikugui.cc_9527/wwwroot/public/" ServerName "1636965547" ServerAlias zb.ikugui.cc #代理设置 SSLProxyEngine On ProxyRequests Off ProxyPreserveHost On RequestHeader set Host zb.ikugui.cc ProxyPass / http://111.229.53.23:8099// ProxyPassReverse / http://111.229.53.23:8099// CustomLog "|/usr/local/phpstudy/system/module/rotatelogs /www/admin/www.ikugui.cc_9527/log/apache_access_%Y-%m-%d.log 86400 480" combined_with_cookie RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R] </VirtualHost> <VirtualHost *:443> DocumentRoot "/www/admin/www.ikugui.cc_9527/wwwroot/public/" ServerName "1636965547" ServerAlias "zb.ikugui.cc" #开启SSL SSLEngine on SSLCertificateFile "/usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_apache_public.crt" SSLCertificateKeyFile "/usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_apache.key" SSLCertificateChainFile "/usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_apache_chain.crt" SSLProtocol all -SSLv3 #代理设置 SSLProxyEngine On ProxyRequests Off ProxyPreserveHost On RequestHeader set Host zb.ikugui.cc ProxyPass / http://111.229.53.23:8099// ProxyPassReverse / http://111.229.53.23:8099// CustomLog "|/usr/local/phpstudy/system/module/rotatelogs /www/admin/www.ikugui.cc_9527/log/apache_access_%Y-%m-%d.log 86400 480" combined_with_cookie </VirtualHost>
nginx-proxy-配置反向代理.conf
server{ listen 80 ; server_name zb.ikugui.cc ; #代理配置 location /{ proxy_set_header X-Original-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host zb.ikugui.cc:$server_port; proxy_pass http://111.229.53.23:8099//; } access_log /www/admin/www.ikugui.cc_9527/log/nginx_access_$logdate.log main; rewrite ^(.*)$ https://$host$1 permanent; } server{ listen 443 ssl; server_name zb.ikugui.cc; #开启SSL ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #证书文件 ssl_certificate /usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_nginx_public.crt; ssl_certificate_key /usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_nginx.key; #代理配置 location /{ proxy_set_header X-Original-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host zb.ikugui.cc:$server_port; proxy_pass http://111.229.53.23:8099//; } access_log /www/admin/www.ikugui.cc_9527/log/nginx_access_$logdate.log main; }
nginx容器的配置demo
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html/public; index index.html index.htm index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html/public; } location ~ \.php$ { fastcgi_pass php:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /www/public/$fastcgi_script_name; include fastcgi_params; } }