Articles of nginx

从源代码升级nginx

在Debian Jessie上,我通过apt-get安装了nginx。 现在我想升级到最新的nginx来利用http2。 我无法将其添加到source.list文件,因为它是一个树莓派。 我下载,编译没有问题,但它安装在不同的位置。 现在,当我nginx -v我得到1.6.3,但如果我/usr/local/sbin/nginx -v我得到1.11.2。 我可以在configuration期间设置安装path,我不知道这是我想要做的。 我想安装1.6的顶部1.11而不是所有的我的网站文件和configuration。 如何从源代码升级nginx并保持我所有的旧configuration?

用于查找index.html的Nginxconfiguration

我正试图完成以下行为: 在文件结构中 /var/html/jpmelos.com/ – index.html – public/ – index.html 如果我访问http://jpmelos.com ,我想获取public/index.html如果文件存在,如果它不存在,我想提示用户input用户名和密码,并获得index.html 。 同样的行为,如果达到http://jpmelos.com/index.html 。 公用文件夹先检查并匹配,然后用密码保护文件夹。 我将这个configuration文件包含在http块中: server { listen 80; server_name jpmelos.com; location / { root /var/html/jpmelos.com/public; index index.html; try_files $request_uri @redirect; } location @redirect { auth_basic on; auth_basic_user_file /htpasswd/jpmelos; root /var/html/jpmelos.com; index index.html; } } 当我到达http://jpmelos.com/index.html是正确的,我得到的文件public/index.html 。 但是当我到达http://jpmelos.com ,它返回一个403 Forbidden 。 我运行Ubuntu 15.10,Nginx 1.11.1。 […]

简单的非正则expression式nginx位置映射

我有一个域www.example.com,这里是我的nginx的configuration location /data { root /var/www.example.com/html; index index.html; } 当我点击http://www.example.com/data时 ,我预计文件/var/www.example.com/html中的index.html将显示出来,但它没有。 path的位置很简单,即使没有正则expression式(我的要求真的很简单)。 我做错了什么? 谢谢

Nginx重写规则核心PHP + WordPress | 无法loginWP-Admin面板

我有一个在核心PHP开发的静态网站(没有框架使用),我也安装了一个博客使用wordpress在同一个域下的子目录。 Like : example.com/blog 由于主站点是使用静态php文件构build的,因此按照SEO推荐,我写了一个简单的重写规则来从URL删除.php扩展名。 所以 http://example.com/abc.php will rewrite to http://example.com/abc 现在到了实际的问题。 当我尝试login到http://example.com/blog/wp-admin并把用户名和密码redirectwp-login.php,但由于上述重写规则它更改为wplogin,并导致找不到redirect404页面在主要站点。 重写规则Nginx的vhost-conf是: location ~ \.php$ { if ($request_uri ~ (.*)\.php$) { return 301 $1; } try_files $uri =404; expires off; fastcgi_read_timeout 900s; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9001; 我知道这可能不是最好的方法,但我已经尝试了几乎几个小时stackexchange几乎所有的答案,最后得到这个使用上面的工作。 我的问题是,如何从这种redirect排除wp-admin? 否则有人可以build议任何替代良好的redirect/重写规则,以避免这种冲突? 完整的Nginxconfiguration: server { listen 80; # Default listen port if ($host = […]

保护Kafka REST API端点

我们计划使用Kafka为我们的客户发布更新。 计划是为每个客户使用专用主题。 为了让事情变得简单,我们希望利用REST API。 因此, user1将能够从/api/topic2获取更新,并且将无法从/api/topic2获取更新(URL仅供参考)。 但是,目前REST API 没有任何authentication/授权。 我想知道我们是否可以通过第三方工具(如nginx)实现我们的目标? 通过在REST API之前放置一些代理或其他任何东西。 谢谢!

nginx多个sub_filter不能正常工作

我在这里有问题。 我已经从apt上安装了nginx,所以它有nginx -V的以下输出: nginx version: nginx/1.6.2 TLS SNI support enabled configure arguments: –with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-se curity -D_FORTIFY_SOURCE=2' –with-ld-opt=-Wl,-z,relro –prefix=/usr/share/nginx –conf-path=/ etc/nginx/nginx.conf –http-log-path=/var/log/nginx/access.log –error-log-path=/var/log/nginx /error.log –lock-path=/var/lock/nginx.lock –pid-path=/run/nginx.pid –http-client-body-temp- path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-proxy-temp-pat h=/var/lib/nginx/proxy –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/l ib/nginx/uwsgi –with-debug –with-pcre-jit –with-ipv6 –with-http_ssl_module –with-http_stu b_status_module –with-http_realip_module –with-http_auth_request_module –with-http_addition _module –with-http_dav_module –with-http_geoip_module –with-http_gzip_static_module –with- http_image_filter_module –with-http_spdy_module –with-http_sub_module –with-http_xslt_modul e […]

如何防止nginx剥离安全的cookie?

我们正在设置cookie上的secure标志 ,而nginx拒绝传送它们,因为我们正在通过HTTP进行通信。 这是完全可以理解的,因为这是预期的行为。 然而,在nginx之前,我们运行一个Classic Load Balancer(以前称为Elastic Load Balancer),它接受来自Internet的HTTPSstream量,并通过HTTP与我们的内部networking上的nginx进行通信。 那么,有没有办法告诉nginx不去掉cookie,因为整个连接是可信的?

Nginxconfiguration无法重新加载。 有“bind()到0.0.0.0:80失败(98:地址已经在使用)”错误

我尝试安装一个HTTPS证书,并且在将我的头靠在墙上几个小时之后,我意识到Nginx并没有拿起我在/etc/nginx/sites-available/ 当我运行service nginx restart它重新启动罚款。 当我运行nginx -t它说我的语法是好的,我的configurationtesting是成功的。 但是,当我运行service nginx reload我得到一个错误,说reload: Not running 当我看着/var/log/nginx/error.log我有这些错误。 2016/08/29 16:04:40 [emerg] 14744#14744: bind() to 0.0.0.0:80 failed (98: Address already in use) 2016/08/29 16:04:40 [emerg] 14744#14744: bind() to 0.0.0.0:443 failed (98: Address already in use) 2016/08/29 16:04:40 [emerg] 14744#14744: bind() to [::]:80 failed (98: Address already in use) 2016/08/29 16:04:40 [emerg] 14744#14744: […]

Nginx,PHP-FPM,在子程序中有2个应用程序

我有2个应用程序在2个不同的文件夹。 我想使用根文件夹除了/ SOMENAME作为URL中的文件夹,在这种情况下,我想指向该文件夹。 我尝试了几个位置/别名块,但没有一个工作(位置是正确的,但PHP文件没有提供只有静态内容)…看到我的configuration下面。 server { listen 80; #disable_symlinks off; server_name join.mydomain.com; #allow few domains root /www/main; #removing the 'index.php' location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php; } index index.html index.php; } location /SOMENAME/ { root /www/somename; } ####################### location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; […]

多个proxy_pass位置与PHP

我想有两个proxy_pass位置和一个通用的php-fpm位置以及任何.php请求被转发到fpm-php,但任何请求/ el / …或/ gl / …去那些位置。 这是我迄今为止: server { listen *:443 ssl; ssl_certificate /etc/nginx/ssl/nginx.crt; ssl_certificate_key /etc/nginx/ssl/nginx.key; client_max_body_size 108M; access_log /var/log/nginx/access.log; root /var/www/public; index index.php; if (!-e $request_filename) { rewrite ^.*$ /index.php last; } location /es/ { proxy_pass http://<my-domain>:8200/; } location /gl/ { proxy_pass http://<my-domain>:3000/; } location / { location ~ \.php$ { fastcgi_pass <my-domain>:9000; […]