server {
listen 80;
charset utf-8;
server_name xxx.com www.xxx.com;
if ($http_host !~ "^www.xxx.com$") {
rewrite ^(.*) http://www.xxx.com$1 permanent;
}
location / {
proxy_pass http://192.168.0.2:80;
proxy_set_header Host $host;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
每日归档: 2017年8月31日
nginx 配置文件
server
{
listen 80;
charset utf-8;
server_name xxxx.xxxx.com;
root /usr/share/nginx/html/cube;
index index.php index.html login.html;
autoindex on;
autoindex_exact_size off;
llangic1014 autoindex_localtime off;
location /ops {
try_files $uri $uri/ /ops/index.php;
}
location /deyuan {
try_files $uri $uri/ /deyuan/index.php;
}
location ~ \.php$ {
index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_buffers 8 128k;
}
}
docker tutum/apache-php 打开Apache rewrite
使用tutum/apache-php 的时候遇到apache没有开启rewrite的问题
我手动开启需要重启apache
但是重启之后容器就自动退出了
我在google上找了好久终于找到可以通过传参的方式启动rewrite模块
docker run -d -p 80:80 -e ALLOW_OVERRIDE=true tutum/apache-php
阿里云内网传文件
scp local_file remote_user@host:remote_folder
解决apache/nginx做反向代理导致request.getServerName()外网环境获取不到代理地址(或域名)的问题
前两天做了个项目,为了给用户演示,需要外网访问,于是配置了apache代理。随之问题就来了,外网访问的时候,request.getServerName()总是获取不到代理服务器的地址(外网域名地址),返回的却是是公司内网地址192.168.x.x。
网上搜罗些资料,发现默认情况下,apache作为代理为了提高性能,一些Http头部信息不回转发给后台服务器,其中就包括代理服务器的host信息,而tomcat中对于request.getServerName()的实现,就是取这个host信息,如果http header总没设置,则取本机IP地址。
所以,要解决这个问题,需要在配置代理的时候,显示告诉代理服务器,需要把代理服务器的Host转发给后台服务:
apache 为:在<VirtualHost/>标签中的最后添加 ProxyPreserveHost on
nginx为:在location {…}中添加 proxy_set_header Host $host;