Articles of nginx

获取Nginx使用/index.php/something

我正在尝试从Apache迁移到Nginx。 我使用的是Nginx 1.8.1和PHP 5.6 Apache接受这样的URL: domain.com/site/index.php/something 并用参数/ something调用index.php脚本。 这是我的WordPress的工作原理,但还有其他脚本依赖。 例如,我可以这样做: domain.com/path/script.php/someparameter 我怎样才能在Nginx中工作? 编辑:我find了WordPress的解决scheme: location /blog/ { try_files $uri $uri/ /blog/index.php?$args; } 但是,对于所有脚本,通用解决scheme是什么?

在Nginx上将自定义域指向服务器

我有我的服务器在Azure Ubuntu 14.04虚拟机上运行。 这工作很好。 现在我想指出我的自定义域,以便用户可以通过访问www.example.com而不是www.example.eastus.cloudapp.azure.com来访问我的网站。 我通过使用以下设置设置CNAME来更改我的域名注册商的DNS设置: 名称: www 价值: example.eastus.cloudapp.azure.com 我的网站www.example.com上显示“欢迎使用Ubuntu上的nginx”! configuration页面,而我的Azure域正确显示我的应用程序。 这是我的Nginxconfiguration(我使用的是Rails的Passenger): server { listen 80; server_name example.eastus.cloudapp.azure.com; # Tell Nginx and Passenger where your app's 'public' directory is root /var/www/example/code/public; # Turn on Passenger passenger_enabled on; passenger_ruby /home/example/.rvm/gems/ruby-2.1.5/wrappers/ruby; } 我做了很多search,似乎无法找出缺less的东西。 我以为在我的DNS设置中更改CNAME就足以让这个工作。 任何有识之士将不胜感激!

使用nginx获取SSL错误

我有一个数字海洋液滴启动和运行,并在我的仪表板159.xxx.xxx.xx,并与nano / etc / nginx / sites-available / hello_world ip我有这个configuration文件: server { listen 80; server_name 159.xxx.xxx.xx; location / { proxy_pass https://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static/ { alias /root/dev/hello_world/staticfiles/; } } 当我在浏览器中访问https://159.xxx.xxx.xx:80 /时,Firefox中出现ERR_SSL_PROTOCOL_ERROR ,Chrome出现ERR_SSL_PROTOCOL_ERROR 。 无论我是否使用gunicorn运行或不使用gunicorn hello_world.wsgi –bind 127.0.0.1:8000 为什么我得到这个错误,我能做些什么来解决它? 预先感谢您的耐心。

在AWS上运行nginx会发回“ERR_CONNECTION_TIMED_OUT”响应

我已经在Ubuntu AWS(EC2)节点上安装了nginx,并确认它正在通过ps -aef | grep nginx运行 ps -aef | grep nginx 。 在server部分我有: server { listen 8080; server_name ec2-<blah>.us-west-2.compute.amazonaws.com; location / { root /opt/derp; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } …其中ec2-<blah>.us-west-2.compute.amazonaws.com是我的EC2实例的公共DNS。 当我重新加载( sudo nginx -s reload )并转到http://ec2-<blah>.us-west-2.compute.amazonaws.com:8080 ,我希望得到默认的nginx“ Welcome! ”页面,但相反,我得到HTTP失败(在Chrome net::ERR_CONNECTION_TIMED_OUT ,这是我得到的最多的信息)。 对我来说,这可能是因为: […]

nginx php-fpm如何禁用日志警告?

我已经用nginx + php-fpm设置了。 我在我的nginx错误日志中发现了很多这样的PHP警告消息: 2016/03/17 20:57:23 [error] 23002#0: *114868 FastCGI sent in stderr: "PHP message: PHP Warning: Declaration of Walker_Category_Filter::start_el(&$output, $category, $depth, $args) should be compatible with Walker_Category::start_el(&$output, $category, $depth = 0, $args = Array, $id = 0) in /var/www/wp-content/themes/venture/functions/theme/custom-post-types.php on line 0 PHP message: PHP Warning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a […]

如何使用nginx与相同的主机,但不同的url用于diff站点

我在端口8080,8090有不同的webistes服务 现在我唯一允许的港口是外面的8085。 有没有可能做到这一点 myserver.com:8085/site1 go to 8080 myserver.com:8085/site2 go to 8090 我要那个 http://www.myserver.com:8085/site1应该去http://myserver.com:8080/site1 Tim编辑 – 从下面的OP问题中添加 我也想 /site1/task 代理到http://example.com:5678/task 我试过这个 location ~ ^/site2(/)?(?<var>\w+)? { proxy_pass http://127.0.0.1:3434/$var; }

如何configurationnginx使用URL的一部分作为头?

我正在尝试运行一个支持多个客户的服务器应用程序。 他们都应该使用自己的URL访问应用程序,例如http://localhost:8082/customer1/config ,但应用程序需要将客户特定部分作为请求标头。 该请求应该被redirect到http://localhost:9002/config 。 我可以做到这一点,如果我写每个客户的位置规则: server { listen 8082; server_name localhost; root /; location /customer1/ { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_cookie_path ~*^/.* /; proxy_set_header X-customer customer1; proxy_pass http://127.0.0.1:9002/; proxy_redirect off; } } 我怎样才能configurationnginx,所以它需要任何客户名称,并将其放入标题?

Nginx – 太多的redirect

对不起,conf文件。 我一直在尝试一切,所以变得一团糟。 我想启用SSL并将所有stream量redirect到https。 目前,使用下面的conf文件,我可以导航到HTTP没有问题。 HTTPS只是redirect回HTTP。 如果我取消注释第5行,那么浏览器只是说太多的redirect。 任何帮助表示赞赏。 更新:基于下面的评论,我更新了conf文件。 同样的问题。 我添加返回301分钟我得到太多的redirect错误。 # Redirect all variations to https://www domain server { listen 80; server_name name.com www.name.com; # return 301 https://www.name.com$request_uri; } server { listen 443 ssl; server_name name.com; ssl_certificate /etc/letsencrypt/live/name.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/name.com/privkey.pem; # Set up preferred protocols and ciphers. TLS1.2 is required for HTTP/2 ssl_protocols TLSv1 TLSv1.1 […]

Nginx wordpress无法在CentOS 6.8上传文件

当我上传一张照片到我的网站时,我不断收到这个错误。 无法创build目录wp-content / uploads / 2016/06 configuration是这样的。 对于/etc/nginx/conf.d/default.conf server { server_name vnfintech.com www.vnfintech.com; root /usr/share/nginx/html; index index.php; access_log /var/log/nginx/vnfintech.com.access.log; error_log /var/log/nginx/vnfintech.com.error.log debug; client_max_body_size 20M; set $cache_uri $request_uri; # POST requests and URLs with a query string should always go to PHP if ($request_method = POST) { set $cache_uri 'null cache'; } if ($query_string != "") […]

nginx上的第二个域redirect到第一个

我有一个服务器,我在域example.eu上运行一个网站。 我已经redirect到https,并根据这个答案删除了www。 我现在希望添加另一个网站到相同的服务器,在域test.eu. 这个服务器不需要www去除或https,所以它是一个简单的服务器块。 问题是,每当我去浏览器中的test.eu,我得到一个301redirect到example.eu。 example.eu conf: upstream django { server unix:///home/foo/bar/example.sock; # for a file socket } server { listen 80; server_name example.eu www.example.eu; return 301 https://example.eu$request_uri; } server { listen 443 ssl; server_name www.example.eu; ssl_certificate /etc/nginx/ssl/example.cer; ssl_certificate_key /etc/nginx/ssl/example.key; return 301 https://example.eu$request_uri; } server { listen 443 ssl; server_name example.eu; ssl_certificate /etc/nginx/ssl/example.cer; ssl_certificate_key /etc/nginx/ssl/example.key; […]