Articles of nginx

如何在Centos 6中删除Apache webserver

我使用Centos 6 64位。 我已经通过Directadmin安装了反向代理NGINX + Apache。 但是我想彻底删除Apache服务并使用NGINX。 我怎样才能做到这一点?

在Tomcat连接器中添加“address = 127.0.0.1”后,JIRA变得不可访问

我将JIRA和Nginx与Nginx安装在同一台服务器上,作为反向代理。 从我从各种来源得知,在server.xml文件中,我必须添加一个地址=“127.0.0.1”属性,以便Tomcat不听外部IP。 但是,一旦我添加到我的8080和8443连接器,事情停止工作,即JIRA网站变得无法访问。 浏览器显示连接被拒绝/连接超时错误。 这里是Tomcat的server.xml文件configuration。 <Connector port="8080" address="127.0.0.1" maxThreads="150" minSpareThreads="25" connectionTimeout="20000" enableLookups="false" maxHttpHeaderSize="8192" protocol="HTTP/1.1" useBodyEncodingForURI="true" acceptCount="100" redirectPort="8443" disableUploadTimeout="true" proxyName=<FQDN> proxyPort="80"/> <Connector port="8443" address="127.0.0.1" SSLEnabled="true" acceptCount="100" clientAuth="false" connectionTimeout="20000" disableUploadTimeout="true" enableLookups="false" keyAlias=<value> keystoreFile=<jks file> keystorePass=<password> keystoreType="JKS" maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS" useBodyEncodingForURI="true"/> 以及启用网站的Nginx服务器configuration链接到站点可用文件夹 – server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name […]

修改nginx中从PHP发送的cookie

我有一个cookie,我需要在Javascript中阅读,所以我需要从它删除cookie的httponly部分。 这是我需要修改的cookie: Set-Cookie: wordpress_c3d46b752402579c18e981091b8c940c=admin%7C1463963639%7CWsIehTVJh4%7C7ee6e8117b6b; expires=Mon, 23-May-2016 12:33:59 GMT; Max-Age=1252800; path=/wp-content/plugins; domain=.example.org; HttpOnly 我只需要去掉cookie尾部的HttpOnlystring PS:我知道我在这里引入了一个潜在的安全问题。

logging特定位置的请求

有同样的问题。 尝试命名的位置,但我总是得到同样的东西,为特定位置(/日历)创build的访问日志是空的,日志存储在一般位置上下文中的访问日志(/)。 如果我从最后一个位置上下文中删除.+\.php$ part,我得到了index.php文件的原始视图,因为^~修饰符。 任何build议如何将请求logging到特定位置? #user root; worker_processes 1; pid /usr/local/nginx/logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; #default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name ip-address; root /var/www; index index.php; access_log /usr/local/nginx/logs/access.log; location / { try_files $uri /index.php; } location ~ \.php$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:8080; try_files $uri […]

nginx:无法设置基本代理(连接拒绝)

我试图设置服务器,我的networking应用程序将被托pipe。 对于每个应用程序,入口点是一个nginx服务器,打包在docker容器中,其端口80被转发到主机上的某个地方。 服务器的端口80由nginx代理服务器监听,它select与Host请求头对应的应用程序。 这里是我简单,完全静态的应用程序的nginxconfiguration: server { listen 80; location / { root /usr/share/nginx/html; index index.html; } } 应用程序的端口80绑定到主机的端口8000。 这里是代理的configuration: server { listen 80; location / { root /usr/share/nginx/html; index index.html; } } server { listen 80; # not real DNS, just an example server_name static.myserver.net; location / { proxy_pass http://127.0.0.1:8000; } } DNSloggingmyserver.net和static.myserver.net绑定到服务器的IP。 但是当我尝试连接到static.myserver.net ,我得到错误502和代理日志条目是这样的: […]

即使我在别处指定日志,nginx也会尝试在/ var中打开日志

我试图运行nginx作为一个非特权用户 – 具体来说,我平常的loginID。 我发现我无法成功启动nginx,因为它坚持尝试在/var/log/nginx/打开日志文件,即使当我提供的configuration文件告诉它将文件存储在别处时也是如此。 具体来说,我这样调用nginx: $ nginx -c ~/my-nginx.conf 该命令中提到的configuration文件具有这种forms: pid /home/me/nginx/nginx.pid; events { worker_connections 1024; } http { access_log /home/me/nginx/access.log; error_log /home/me/nginx/error.log; # many more lines omitted } 省略的行都不包含access_log或error_log指令,也不包含通过include指令包含的less数几个文件。 打印这些行后,nginx总是死掉: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2016/06/13 12:43:54 [emerg] 4473#0: open() "/var/log/nginx/error.log" failed (13: Permission denied) […]

Docker如何Django + uwsgi / gunicorn + nginx?

我无法弄清楚部署一个使用uwsgi / gunicorn的Django项目的“正确”方式(我还没有决定使用什么,可能uwsgi,因为它有更好的性能,build议?)和nginx使用泊坞窗。 我看到有些人把所有东西放在同一个容器里。 我不是docker专家,但是容器应该只做一件事情。 所以,Django + nginx似乎是2而不是1。 现在,我的部署思路是: 一个容器与Django和uwsgi。 在Dockerfile的最后我运行uwsgi脚本。 这个容器暴露了端口8000 一个与django链接的nginx容器。 这暴露了端口80,并将请求代理到Django。 有没有其他办法可以做到这一点? 有一个教程,涵盖了这个案件更​​深入一点。 我需要一个坚实的生产,而不仅仅是testing我的电脑上的一些代码。

即使在完全安装之后,服务器上的每个网站都会redirect到外部页面

首先,这是我第一次在这里发帖,很抱歉,如果我张贴在错误的部分。 要做到这一点:我有一个CentOS 7 + Gnome服务器,configurationVestaCP并运行2个WordPress网站。 上周,我注意到他们已经脱机了,我无法SSH进入服务器。 当我物理login到服务器,我注意到,一切都redirect到一个单一的网页,它说,该网站正在维护。 好奇的是,该页面包含文本 这是1stweb.de 如果我访问那个页面,我会得到完全一样的东西。 我做了什么: 从一切正常工作时恢复备份; 重新configuration网站的.htaccess文件; 重新安装了VestaCP; 做了一个全新的操作系统,Vesta和恢复备份。 即便如此,我也得到了同样的结果。 让我更加好奇的是,当我检查页面时,我注意到了两件事情: – 它从mydomain.com /website-under-maintenance.png加载一个不存在的图像; – 检查访问任何网站时所做的networking请求,我看到这样的: 这是1stweb.de网站在维护将NANOMITES转移到您的计算机 如果我在Google上search那个页面,我没有得到任何与Google相关的内容。 有什么我错过了吗? 我没有很多的经验,所以我可能做错了什么,但我无法弄清楚。

try_files只有一个@location?

我从https://gist.github.com/mattd/1006398开始,现在我有这个: root /data/example.com; location /sites/default/files/ { try_files $uri @proxy; } location / { try_files @proxy; } location @proxy { proxy_pass http://127.0.0.1:8088; } 当然,这是无效的语法。 我怎样才能做这个工作? 基本上,我希望sites/default/files文件直接提供文件,如果它存在和使用@proxy否则。 其他目录应该立即去@proxy 。 我不想复制粘贴@proxyconfiguration,因为会有更多的添加(caching)。 我也将有其他的目录,例如直接提供.well-known 。

nginx子目录通配符重写

我已经在我的nginx服务器上build立了一个服务器模块,例如域testsite.com 。 我希望能够将独立的WordPress安装安装到根文件夹的直接子文件夹中,例如/var/www/html/testsite.com/ childfolder1 ,/var/ www / html / testsite.com / childfolder2等,所以他们可以通过testsite.com/ childfolder1 ,testsite.com/ childfolder2等访问 。 手动创buildredirect的方法是像这样插入它: location /childfolder1 { index index.php; try_files $uri $uri/ /childfolder1/index.php?$args; } 并重复每个网站来。 使用location /只覆盖根目录。 有没有办法创build一个(正则expression式?)通配符规则,说:“对于每个直接子目录,应用这个try_files命令”(这显然总是相同的WordPress,只是文件夹名称更改)? location /*anydirectsubdirectory* { index index.php; try_files $uri $uri/ /*anydirectsubdirectory*/index.php?$args; }