我使用cakephp作为我的项目。我在/ etc / hosts中创build了本地dns文件夹,位于/var/sites.My,nginxconfiguration看起来像 location /{ add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; root /var/sites/$host/app/webroot; index index.php index.html; } 在cakephp 3.x中,index.php的位置是/var/sites/$host/webroot。如何处理不同项目中index.php多个位置的场景。
这可能是一个noob问题,但我仍然在学习Web服务器和反向代理设置。 我有两台服务器在同一个networking上运行 – 一个Tomcat和另一个Nginx,我打算为类似的Tomcat服务器使用反向代理服务器。 我了解到可以用来隐藏真实Web服务器的身份,并且可以利用其他优点,例如更好的性能和负载平衡,我提出了引入反向代理服务器的想法。 我面临的问题是,tomcat服务器可以通过两个IP地址访问 – 如果我使用Nginx IP,它将redirect到Tomcat FQDN(预期),但是如果使用FQDN tomcat.domain.com进行ping,则会显示真实Tomcat服务器的IP,而不是Nginx服务器的IP。 实际上,我的Nginx服务器没有任何用途。 我在这里错过了什么?
我有一个nginx负载均衡器设置2个网站。 负载均衡器的IP地址是192.168.123.10我想在本地访问这两个站点来检查是否一切正常。 但是我对主机名和域名感到困惑。 我给了第一个站点的主机名:“testing”和一个域名“mytest.local”。 我在手册中读到,如果我想访问站点,我应该去test.mytest.local,并使该地址的DNS指向负载均衡器的IP。 但我不明白我的电脑怎么知道我想要哪个站点,因为如果我负载平衡的其他站点是anothertest.mytest.local,并且它parsing为相同的IP,这将如何不同呢? 我没有设置任何DNS,我只是想检查Nginx是否工作,所以我仍然可以访问本地的网站test.mytest.local? (没有build立一个DNS)?
我有两个服务器块 server { listen 80 default_server; listen 443 default_server ssl; server_name www.example.com example.com; root /var/www/webpage index index.php; client_max_body_size 3800m; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { try_files $uri $uri/ /index.php?q=$uri&$args; } # pass the PHP scripts to FastCGI server […]
我有一个Nginx的testing环境,我有2个服务器块。 首先是使用server_name .DomainA.; 第二个是使用server_name DomainB.com; 除此之外,我的客户机的hosts文件已经将www.DomainA.test设置为服务器的IP,而我的服务器的hosts文件将DomainB.com设置为127.0.0.1。 我在用: curl www.DomainA.test/a_test 打我的初始位置: location /a_test { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://DomainB.com/b_test; } 现在,我的DomainB.com服务器块,我有这个位置: location /b_test { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; return 200 "<html><head><title>Test :)</title></head><body>You are speaking to $host (B server)<br/>You have found $host:$server_port $request_uri</body></html>\n"; } 有了这个configuration,对于上面的curl,我得到了404。我偶然发现,如果我为.DomainA添加一个/ b_test位置。 服务器,从那里的结果将返回,所以显然不是要解决DomainB.com。 为DomainB.com添加上游(仅指向127.0.0.1)不会改变结果。 这是一个Nginx的怪癖,当我proxy_pass到相同的IP地址时,它不会查看其他服务器块吗? 或者也许我错过了文档中的某些东西? 这是可以/应该重写或proxy_redirect处理? 我的目标是向www.DomainA.test […]
我的应用程序在Amazon EC2 t2.small实例上提供。 使用ab命令testing性能时。 ab -n 3000 -c 100 mydomain.com HTTP Finished 3000 requests Server Software: nginx/1.8.1 Server Hostname: www.mydomain.com Server Port: 80 Document Path: / Document Length: 184 bytes Concurrency Level: 100 Time taken for tests: 3.201 seconds Complete requests: 3000 Failed requests: 0 Non-2xx responses: 3000 Total transferred: 1401000 bytes HTML transferred: 552000 […]
我通常是一个Apache用户,但我需要开始使用nginx作为smtp(后缀)的反向代理。 我在网上看过几十个例子。 像这样和这个 。 他们都有一个auth_http条目,我完全不明白。 这不是我第一次使用代理,而且我目前使用haproxy已经有几个月了。 那么,为什么我必须提供一个PHP身份validation页面? 为什么我不能像使用haproxy一样简单地使用nginx,只要告诉它:在这里设置一个前端,用这个密钥解密ssl,并把它带到后端/端口? 有人可以解释auth_http条目是多么必要吗? nginx手册似乎不太多。 感谢您的努力。
我甚至不知道我在做什么名字,这就是为什么问题的标题可能是不正确的。 在我的本地(Mac)计算机上,当在网站上工作的域名DNS仍指向不同的服务器时,我更新本地private/etc/hosts文件: 45.55.183.249 domain.com 其中45.55.183.249是主机的地址。 我希望这台远程计算机也能查find45.55.183.249 (localhost?)的domain.com请求。 我正在使用nginx。 我想这可以通过/etc/nginx/nginx.conf来完成,或者,因为我只通过include sites-enabled/*;托pipe单个站点include sites-enabled/*; : /etc/nginx/sites-enabled/domain.com.conf 简单的内容就是这个要点 。 我注意到这个问题的原因,如果我完全偏离轨道,是以下错误: FastCGI sent in stderr: "PHP message: PHP Warning: file_get_contents(http://domain.com/app/themes/themename/dist/images/arrow-down.svg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found \ in /srv/www/domain.com/releases/20160519122018/web/app/themes/mytheme/front-page.php \ on line 20" while reading upstream, client: 108.205.62.184, server: domain.com, request: "GET / HTTP/1.1", \ […]
我使用Nginx来托pipe一个configuration为专门使用SSL的WordPress站点。 前段时间,我激活了严格的SSL选项和Cloudflare的HSTS选项。 现在我想禁用它,只使用我的SSL证书。 问题是,如果我从Cloudflare禁用SSL和HSTS,当我尝试访问我的网站时,出现“太多redirect”错误。 我从浏览器中删除了cookies并刷新了页面,但是仍然给了我相同的错误。 我不记得在Cloudflare上启用HSTS ans SSL之前对我的Nginxconfiguration做了任何特别的处理,但是我想这个redirect问题来自Nginx。 我该如何解决这个问题?
我有下面的configuration。 但是,当用户从http切换到https时,会话不会再停留。 例如。 主页http,但付款页面是https。 我如何解决这个问题? upstream backend { ip_hash; server <server-1-ip>; server <server-2-ip>; } upstream backend_ssl { ip_hash; server <server-1-ip>:443; server <server-2-ip>:443; } server { location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } server { listen 443 ssl; ssl_certificate /etc/nginx/ssl/mycert.crt; ssl_certificate_key /etc/nginx/ssl/mykey.key; location / […]