Articles of nginx

如何在Nginx中将Cloudflare IP作为额外的FastCGI参数存储?

我需要能够知道连接到我的服务器的Cloudflare IP。 这是我可以确定是否通过Tor进行连接。 要做到这一点,我需要发送客户端连接到的IP的工具。 这不是我的服务器的IP,也就是Cloudflare入口代理的IP,这就是为什么我要通过fastcgi传递Cloudflare IP。 https://www.torproject.org/projects/tordnsel.html.en 我有一个块,看起来像这样: # Preserve Cloudflare IP fastcgi_param CF-Proxy-IP $remote_addr; fastcgi_param TEST "abc123"; # CloudFlare set_real_ip_from 199.27.128.0/21; set_real_ip_from 173.245.48.0/20; set_real_ip_from 103.21.244.0/22; set_real_ip_from 103.22.200.0/22; set_real_ip_from 103.31.4.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 108.162.192.0/18; set_real_ip_from 190.93.240.0/20; set_real_ip_from 188.114.96.0/20; set_real_ip_from 197.234.240.0/22; set_real_ip_from 198.41.128.0/17; set_real_ip_from 162.158.0.0/15; set_real_ip_from 104.16.0.0/12; set_real_ip_from 172.64.0.0/13; set_real_ip_from 2400:cb00::/32; set_real_ip_from 2606:4700::/32; set_real_ip_from 2803:f800::/32; set_real_ip_from […]

如果没有使用error_page找不到请求的url,请让nginx服务于index.html

我有nginxconfiguration为服务单页React.js应用程序作为静态内容。 react-router在浏览器中处理路由。 为了使用户能够直接在地址栏中input所有的url(不仅仅是域example.com ,还包括像example.com/some/path等)我在做, error_page 404 /index.html 除了在Internet Explorer中,这在任何地方都可以工作。 IE显示了404页面。 如果请求path无法与根目录中的文件匹配,如何configurationnginx以使其服务于index.html。 谢谢。

下载nginx PHP文件而不是执行

我正试图实现以下的事情。 我有根域目录下的主要网站。 这工作正常。 即PHP文件被执行。 一段时间后,我添加了基本的HTTP身份validation“auth”目录。 接下来,我将PHP程序上传到“auth”目录,但PHP文件正在下载而不是执行。 domain.name/test.php – >执行 domain.name/sub/file.php – >执行 domain.name/auth/protected.php – >下载而不是执行 这里是网站可用的conf 服务器{ charset utf-8; 听80 default_server; 听[::]:80 default_server; root / var / www / html; #如果您使用PHP,请将index.php添加到列表中 index index.php index.html index.htm index.nginx-debian.html; server_name xxx.com; 位置 / { #首先尝试作为文件服务请求,然后 #为目录,然后回退到显示404。 #try_files $ uri $ uri / = 404; try_files $ uri $ […]

sslcurl不起作用

我build立了我的网站我有ssl安装和工作,在镀铬工作正常,工作正常的邮递员。 无论什么原因,当twilio或curl进入它时,它都不起作用。 它使我无法获得本地发行人的错误。 即时消息试图去工作的url是https://anova.me/call/voice?phoneNumber=这是一个后端点 我已经安装了一个运行在独angular兽和nginx上的rails 4 webapp。 我从comodo获得的ssl证书 你可以尝试https://anova.me/ ,看看它的工作原理。 我的nginx看起来像: upstream app_server { server unix:/var/run/unicorn.sock fail_timeout=0; } server { listen 80; root /home/rails/companiontv/public; server_name anova.me; index index.htm index.html; listen 443 ssl; ssl on; ssl_certificate /home/rails/anova_me.crt; ssl_certificate_key /home/rails/anova.key; location / { try_files $uri/index.html $uri.html $uri @app; } location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ { try_files $uri @app; } […]

NGINX在CentOS 7上的phpMyAdmin返回空白页面

我用NGINX在虚拟机上安装了CentOS 7。 PHP,MariaDB和其他一切安装和工作正常。 但是,当我访问http:// localhost / phpMyAdmin它显示空白页面。 有人知道为什么 我的nginx.conf如下: user nginx; worker_processes 1; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { # Upstream to abstract back-end connection(s) for PHP upstream php { server unix:/var/run/php-fpm/php-fpm.sock; } include mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" […]

Nginx代理不能按预期工作

我用nginx在主机上使用dokku(小heroku),我的容器是使用apache,它暴露的端口8052。 这是启用和工作正常的.conf里面的configuration: LISTEN 8052 <VirtualHost *:8052> ServerAdmin veeenex@localhost DocumentRoot /var/www <Directory /> Options +FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options +FollowSymLinks +ExecCGI AllowOverride All Order allow,deny allow from all </Directory> FCGIWrapper /phpfarm/inst/php-5.2/bin/php-cgi .php AddHandler fcgid-script .php LogLevel warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 这是主机上的configuration upstream katalog.domain.eu { server 172.17.0.3:8052; } server { listen [::]:80; […]

Nginxurl与重写美化

目前我有我自己的域名示例,如abc.com,但是当我点击另一个页面在abc.com我看到该url有太多的东西,然后我期望,像下面的代码 abc.com/index.html?utm_expid=122964311-0.Ij_8kYLEQneeCz7Rwkt0HA.0&utm_referrer=http%3A%2F%2Fwww.abc.com%2Fpartner.html 我可以知道如何使用nginx重写,使它美丽? nginx.conf server { listen 80; server_name abc.com www.abc.com; root /web/abc/www/phone/; index index.php index.cgi index.pl index.html index.htm; charset utf-8; access_log logs/abc.access.log ; location / { try_files $uri $uri/ /index.html?$args; } 请帮助,先进的感谢。

WordPress的pipe理员不能编辑文件

我最近在vps上安装了wordpress。 所有的主题文件的权限设置为644.所有权已经给予根。 但仍然WordPress的pipe理员似乎无法find文件编辑器中的“更新文件”button,除非我设置权限为777.不是WordPress的pipe理员认为是根? 我在Centos 6上。也试过按照命令,但没有发生任何事情 sudo usermod -aG root $USER sudo chown -R root:root /var/www/html 我该怎么办? 权限的屏幕截图

Nginx的别名不起作用

我正在尝试将位置为^/[a-z0-9]{24}$所有stream量传递到另一个根目录下的index.html。 我有我的configuration如此设置: server { listen 80; server_name example.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name example.com; root /Users/me/sites/store_front/static; index index.html; try_files $uri $uri/ $uri.html =404; location ~ "^/[a-z0-9]{24}$" { alias /Users/me/web_app/static; try_files $uri index.html; } } 由于某种原因,当我curl这个URL我得到一个404: $ curl -I https://example.com/55c898e7faa137f42409d403 HTTP/1.1 404 Not Found Server: nginx/1.8.0 Content-Type: text/html; charset=UTF-8 Content-Length: 168 […]

NGINX将子域名redirect到主域名

我有两个网站在我的服务器上运行,一个Wordpress网站和一个运行在端口8080上的networking应用程序。我想将mysite.com和www.mysite.com指向WordPress的网站和app.mysite.com以指向web应用程序使用NGINX。 我已经做了2个独立的configuration,如下所示 – mysite.com server { listen 443 ssl; server_name www.mysite.com mysite.com; < ssl configs > include global/restrictions.conf; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } server { listen 80; server_name mysite.com www.mysite.com; return 301 https://$host$request_uri; } app.mysite.com server { listen 443 ssl; server_name app.mysite.com; < ssl configs > […]