Articles of nginx

Nginx内部redirect

背景:我有一个客户端在控制DNS服务器和域名,曾经指出他的域名X到我的服务器。 他不能再做任何改变(他不知道如何改变,也不能被打扰)。 我在他的服务器上托pipe一个WordPress的博客。 现在,我想停止在我的服务器上托pipe博客,而是将其托pipe在托pipe的WP托pipe服务器(称为wpengine.com)上,但是我不能要求客户端指向他的DNS,他赢了不这样做。 所以我需要通过服务器指令实现从我的服务器到WPENGINE的redirect。 我正在使用Nginx。 我想达到的是: DNS服务器将他的域X.com指向我的服务器Y. 我的服务器Y将他的域Xredirect到wpengine服务器Z. URL栏显示他的域X,而在内部我加载并显示Z服务器的内容 另外值得注意的是,WPENGINE允许使用自定义域,但是它们使用CNAME指针( http://wpengine.com/support/how-to-configure-your-dns/ )。 我只是testing,如果我可以通过服务器转发绕过这一点。 感谢您的帮助或指针。

uwsgi + Django与nginx:高可用性设置

从https://stackoverflow.com/questions/25304968/uwsgi-django-with-nginx-high-availability-setup移到这里。 我在RHEL 6.5上设置了高可用性。 我的堆栈是 1. uwsgi 2. nginx 3. django 4. Pacemaker 现在我明白了,可以通过监视nginx_status轻松设置nginx location /nginx_status { # Turn on nginx stats stub_status on; access_log off; # Security: Only allow access from 192.168.1.100 IP # allow 127.0.0.1; # Send rest of the world to /dev/null # deny all; } 这将确保nginx的心跳监视。 但是,我的问题是如何确保uwsgi将处于运行状态,以便当第二个nginx机器启动时它会识别uwsgi进程并将其绑定到它。 或者,如果uwsgi发生故障,如何确保将其恢复并重新绑定到nginx 设置如下 假设集群机器: 1. xxxx […]

Nginx服务器端口8081根文件夹path

我试图在我的Nginx服务器上使用密码保护所有8081端口。 这个端口唯一使用的是PhpMyAdmin。 当我导航到https://www.example.com:8081时 ,我成功获取了默认的Nginx欢迎页面。 但是,当我尝试导航到PhpMyAdmin目录时, https: //www.example.com:8081/phpmyadmin,我得到一个“404未find”页面。 我的htpasswd文件的权限设置为644。 这是我的服务器块的代码: server { listen 8081; server_name example.com www.example.com; root /usr/share/phpmyadmin; auth_basic "Restricted Area"; auth_basic_user_file htpasswd; } 我也尝试完全评论#root / usr / share / phpmyadmin; 但是,这并没有什么区别。 我的问题局限于使用不正确的根path吗? 如果是这样,我怎么findPhpMyAdmin的根path? 如果它有什么区别,我使用Ubuntu 14.04.1 LTS与Nginx 1.4.6和ISPConfig 3.0.5.4p3。

Nginx的正则expression式configuration为404图像

我有如下的dynamic链接系列; http://example.com/users/1871233/18712443_cover.jpg 只有静态的东西在这个链接是example.com/users和_cover.I想要做到这一点; 当没有find请求时返回一个JPG location ~ ^\/users\/(.*)\/(.*)_cover.*(jpg|jpeg|png|gif)$ { error_page 404 /deff_images/empty-cover-jpg.jpg; } 我做了上面的smt,但没有工作。 我能为此做些什么? 那谢谢啦

反向代理从nginx中的多个主机中过滤掉js文件

我有一个网站http://someplace.acme.com ,我希望我的用户通过访问http://myplace.mycorp.com – 非常标准的反向代理设置。 特殊要求:任何js文件 – 要么由.js扩展名和/或MIMEtypes(如果可能的话)标识文本/ JavaScript需要从一个不同的位置,一个本地工具,检查js的潜在威胁。 所以我有 location / { proxy_pass http://someplace.acme.com; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~* \.(js)$ { proxy_pass http://127.0.0.1:8188/filter?source=$1; proxy_redirect off; proxy_buffering off; } JS仍然是从远程服务,我不知道如何检查MIMEtypes。 我错过了什么?

无法启动Nginx从源代码编译

我正在尝试从我的DigitalOcean服务器( Ubuntu-14.04 64x )上运行的原始编译的Nginx服务器的源代码编译Nginx,但有一些额外的模块。 我可以安装一切顺利,但我无法启动它。 我确定ini是正确的,因为我将当前正在运行的Nginx服务器的原始源文件复制下来[尽pipe我看到Nginx现在在编译fron源文件时添加了ini。 下面是我正在执行的[漫长的过程] – 增加对不起,但我想为需要信息的人彻底。 因为我是Nginx的newB,所以我肯定我错过了一些东西,或者只是把它全错了。 如果你可以看看我已经做了什么,看看你是否需要改变任何东西,我将不胜感激。 日Thnx! 原始的Nginx服务器仍在运行: 我检查当前/正在运行的Nginxconfiguration,以便可以构build新的Nginx实例,但使用添加的模块: nginx -V # The out-put: configure arguments: –with-cc-opt='-g -O2 -fstack-protector –param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' –with-ld-opt='-Wl,-Bsymbolic-functions -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-path=/var/lib/nginx/proxy –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/lib/nginx/uwsgi –with-debug –with-pcre-jit –with-ipv6 –with-http_ssl_module –with-http_stub_status_module –with-http_realip_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_module […]

Nginx内部重写位置以提供静态内容

我试图从端点的静态内容的层次结构不同于实际的根目录结构。 这是我试图达到的结果: 0.0.0.0/Claw/scripts/main.js -> /home/ubuntu/Claw/public/scripts/main.js 我正在使用下面的Nginxconfiguration: location ~ ^/Claw/(images/|styles/|scripts/) { root /home/ubuntu/Claw/public; access_log off; expires max; } 这是因为/home/ubuntu/Claw/public/Claw/scripts/main.js不存在。 因此,我需要从内部删除前缀爪 。 我怎么能这样做? 我想要这个结构,所以我可以在同一个域上托pipe来自不同端点的多个节点应用程序。

在第二个相同的情况下下载nginx php文件

server { listen 80; server_name example.com; root /srv/www/example.com; access_log /srv/www/example.com/logs/access.log; error_log /srv/www/example.com/logs/error.log; location / { index index.html index.php; } location /site1 { try_files $uri $uri/ /index.php; index index.php index.html; root /srv/www/example.com; } #Pass the PHP scripts to FastCGI server location ~ /site1/.+\.php$ { set $php_root /srv/www/example.com; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name; include fastcgi_params; […]

重启Ubuntu 14.04后,nginx不会启动

我得到这个错误: nginx:[emerg]在/etc/nginx/sites-enabled/django.save:1中重复上游“app_server” 这是我的configuration文件: upstream app_server { server 127.0.0.1:9000 fail_timeout=0; } server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm; client_max_body_size 4G; server_name _; keepalive_timeout 5; # Your Django project's media files – amend as required location /media { alias /home/django/django_project/django_project/media; } # your Django project's static files – amend as […]

Nginxredirect特定的文件扩展名

我无法为Magento扩展程序设置redirect。 请求的url是: example.com/index.php/Cdiscount/Package/download/type/offers/filename/BMS_PREFIX_161d529d7c3ef4b5ae1dca92e2334de6/BMS_PREFIX_161d529d7c3ef4b5ae1dca92e2334de6.zip 但是nginx应该返回: example.com/index.php/Cdiscount/Package/download/type/offers/filename/BMS_PREFIX_161d529d7c3ef4b5ae1dca92e2334de6 代替。 BMS_PREFIX_和.zip之间的部分经常会改变,所以这可能会提取所有提供/位置中的.zip文件请求。 我不是100%确定如果在文件中的文件名 offers/filename/BMS_PREFIX…可configuration为其他东西或更改每个请求,但我认为它不会改变。 所以基本上我需要告诉Nginx在请求example.com/path/时候用example.com/path/回复。 当前configuration: location / { proxy_pass http://127.0.0.1:6081; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_hide_header X-Varnish; proxy_hide_header Via; proxy_hide_header Vary; proxy_hide_header X-Server; proxy_hide_header X-Backend-Server; proxy_hide_header X-Frame-Options; proxy_redirect off; proxy_max_temp_file_size 0; proxy_connect_timeout 7200; proxy_send_timeout 7200; proxy_read_timeout 7200; proxy_buffer_size 256k; proxy_buffers 4 512k; […]