我正在使用Nginx的反向代理到apache2使用以下教程 。 然后,我尝试使用本教程将geoip安装到Nginx 反向代理完美地工作了一段时间,直到我试图安装geoip数据库,所以我可以在PHP上获得国家代码。 我有以下的nginxconfiguration为教程指示。 location ~ \.php$ { # location / { #fastcgi_pass unix:/run/php/php7.0-fpm.sock; #include snippets/fastcgi-php.conf; proxy_pass http://1.2.3.4:8080$request_uri; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code; proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3; proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name; proxy_set_header GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code; proxy_set_header GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3; proxy_set_header GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name; proxy_set_header GEOIP_REGION $geoip_region; proxy_set_header GEOIP_CITY $geoip_city; […]
我很确定我错过了一件显而易见的事情,但是这让我疯狂,我需要其他的眼球。 我得到了一个插件的应用程序来源是像这样组织的: / app / plugins / foo / www / …对应于我的urlhttp://example.com/plugins/foo/ … 我将下面的代码片段作为nginxconfiguration: location /plugins/foo { alias /app/plugins/foo/www; try_files $uri /index.php =404; } location ~* ^/plugins/foo/(.*\.php)$ { alias /app/plugins/foo/www/$1; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 它适用于以下url: http://example.com/plugins/foo/style/style.css http://example.com/plugins/foo/index.php http://example.com/plugins/foo/bar.php 但只要我试图达到(前控制器模式): http://example.com/plugins/foo/?id=5 http://example.com/plugins/foo/another/path 我得下载php文件。 根据日志,try_files似乎做预期的,而不是内部redirect到PHP处理程序,它服务器文件为静态: 2017/01/24 13:29:36 [debug] 20803#0: *6 using […]
Nginx似乎caching我的PHP文件 ,因为它服务于同一个PHP页面,即使我改变了服务器上的文件。 我在用: 由Digitalocean发布的Ubuntu 16.04 Droplet nginx / 1.10.0(正常LEMP 一键安装) PHP 7.0.13-0ubuntu0.16.04.1 我尝试了不同的机器,问题依然存在。 我在Apache2上进行了testing,php文件正在按预期更新。 所以我认为问题在于Nginx。 debugging过程:新服务器和新鲜的LEMP安装: 根据这个网站 , 编辑nginx.conf把sendfile on改为sendfile off 。 然后用nginx -s reload重新加载nginxconfiguration(参见下面的nginx.conf文件) 为test.mypersonalsite.com 创build新的服务器块 (请参阅下面的服务器块文件) 将服务器块链接到sites-enabled了sites-enabled目录 sudo ln -s /etc/nginx/sites-available/test.mypersonalsite.com /etc/nginx/sites-enabled/ 用nginx -t 检查并重新启动nginx ,然后sudo systemctl restart nginx 创buildindex.html和index.php部署到服务器(Works完美) 直到这里一切正常,在这之后它错误 将index.html和index.php从v1.0.7更新到v1.0.8 更改后index.php不会重新加载。 尽pipeindex.html确实如此。 这意味着,如果我通过我的浏览器请求网站,我得到旧的PHP文件,而不是在服务器上的新的。 如果我ssh进入服务器和sudo nano的PHP文件,它仍然不会更新。 这似乎是phpcaching在服务器上。 我试图从不同的机器访问该网站。 同样的问题。 题 我在网上search了很多。 大多数解决scheme围绕着将nginxconfiguration设置为sendfile […]
我有两个服务器块。 两者都做了类似的事情:允许我使用https。 现在我只是想知道,在一种情况下,我redirect从http到https的所有stream量。 在另一个它似乎好像我允许HTTPS。 有人可以向我解释,有什么不同? 因为当我请求我的域名时,即使使用http://test.example.com ,我仍然可以在两种情况下redirect到https。 有什么区别吗? 这是两个文件: 文件1-将httpredirect到https server { listen 80; listen [::]:80; server_name test.example.com return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; root /var/www/test/staging/current; index index.php index.html index.htm index.nginx-debian.html; server_name test.example.com; include snippets/ssl-test.example.com.conf; include snippets/ssl-params.conf; location / { try_files $uri $uri/ =404; } } 文件2 […]
我试图将rewrite rules从.htaccess文件转换为nginxconfiguration。 作为移动网站到NGINXnetworking服务器的一部分。 这里是从.htaccess文件重写规则 Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} !\.php$ RewriteCond %{REQUEST_URI} !\.gif$ RewriteCond %{REQUEST_URI} !\.jp?g$ RewriteCond %{REQUEST_URI} !\.png$ RewriteCond %{REQUEST_URI} !\.css$ RewriteCond %{REQUEST_URI} !\.js$ RewriteCond %{REQUEST_URI} !\.html$ RewriteCond %{REQUEST_URI} !\.xhtml$ RewriteCond %{REQUEST_URI} !\.htm$ RewriteCond %{REQUEST_URI} !\.ico$ RewriteRule (.*) index.php [L] RewriteRule (.*).html index.php [L] 我当前的nginx config 。 server { listen 80; server_name example.com; […]
我对nginx的工作人员不太熟悉,所以我需要一些帮助。 我有一个服务器上的两个网站 http://example.com http://example-second.com 第二个是通过第一个API调用接收json数组。 这是情况。 在http://example-second.com/api_call.php文件中有 function get_curl($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); $result = curl_exec($curl); curl_close($curl); return $result; } $url=get_curl("http://example.com/api.php?ID=foo"); 在http://example.com/api.php function get_curl_from_api($url) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_HEADER=> 0, CURLOPT_RETURNTRANSFER=> 0, CURLOPT_SSL_VERIFYPEER=> 1, CURLOPT_SSL_VERIFYHOST=>2 )); $resp = […]
我有一个简单的nginx服务器来监视请求并将它们存储在访问日志中。 请求包含查询参数中的数据,大约500字节。 我的输出只是一个HTTP 204响应。 但是,当我监视networking带宽时,我看到传入速率为8.44 Mbit / s,传出速率为5.19 MBit / s。 问题是,为什么传出率很高? 下面是“tcpflow -p -C -i eth0 port 80”的输出。 GET ############## HTTP/1.1 Host: ############## Accept: */* Accept-Encoding: gzip, deflate, sdch Accept-Language: en-GB,en-US;q=0.8,en;q=0.6 Forwarded: for="[############]" Origin: ########### Referer: ######### Save-Data: on Scheme: http Via: 1.1 Chrome-Compression-Proxy X-Forwarded-For: ################# Connection: Keep-alive User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; SM-J710FN […]
我正在将我的网站迁移到另一个平台,但在完成新网站的所有页面开发时,我需要我的用户在两个平台之间进行导航。 所以我需要对包含1个单词的所有URL进行301redirect,但不包含其他单词: 例: 旧网站:www2.misite.com 新网站:www.misite.com 我需要redirect包含单词“www2.misite.com/travel(.*)”的所有url,但不包含“预订”和“酒店”等字样。 我的服务器是Nginx,我不知道这是用正则expression式还是用nginx语句完成的。 非常感谢你。
我无法获得nginx负载平衡与ip_hash启用内部连接。 我需要粘性会话,因为我在后端使用meteor,但是所有的请求总是碰到相同的后端。 nginx访问日志文件显示以下IP地址: 192.168.0.20 – – [xx/xxx/2017:xx:xx:xx +xxxx] "GET /favicon.ico HTTP/1.1" 404 5 "http://xxxx.lokal/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" 192.168.0.11 – – [xx/xxx/2017:xx:xx:xx +xxxx] "GET /sockjs/602/dpkl6lfe/websocket HTTP/1.1" 101 55045 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" 192.168.0.208 – – [xx/xxx/2017:xx:xx:xx +xxxx] "GET […]
我有一个静态网站Angular网站,我想要path/部署运行一个PHP的PHP脚本/var/www/app/deploy/deploy.php。 我已经尝试了重写规则,没有运气。 什么是正确的方法来做到这一点? php.conf index index.php index.html index.htm; location ~ \.php$ { try_files $uri =404; fastcgi_intercept_errors on; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php-fpm; } vhost.conf server { listen 80; server_name app.com; root /var/www/app/; include /etc/nginx/default.d/php.conf; location / { root /var/www/app/frontend/dist; try_files $uri $uri/ /index.html =404; rewrite ^/deploy /var/www/app/deploy/deploy.php; } }