我希望即使在configtest失败的情况下也能重新加载nginx。 为什么我要这个? 那么在我的情况下,多个用户可以修改nginxconfiguration。 最初这些configuration在语法上是正确的,但我必须记住,用户可能不会提交一个有效的configuration。 有一些钩子重新加载nginx,但没有挂钩的行动,如当用户修改一个nginxconfiguration。 是否有可能重新加载nginx并忽略configuration中的所有更改没有通过testing? 所以它使用那个无效configuration的稳定版本。
我有一个名为http://localhost.example.com的本地网站,但现在当我尝试在networking浏览器中打开它时,它将我redirect到http://www.example.com 。 这曾经工作过。 我在系统中修改的是AWS CLI和Bitbucket本地configuration的configuration,以便使用两个不同的帐户。 而已。 我相信这些变化是无关紧要的。 不是吗? 我提供的所有信息和文件都来自本地工作站。 我正在使用OS X 10.12(testing版2)。 / etc / hosts的相关部分是这样的: 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost 127.0.0.1 localhost.example.com 127.0.0.1 babydiapi.example.com 127.0.0.1 localhost.mi.example.com 127.0.0.1 localhost.qr.example.com 127.0.0.1 localhost.pay.example.com 127.0.0.1 playground.com 127.0.0.1 payments.com 127.0.0.1 localhost.comunidad.example.com 198.58.110.224 web1.example.com 198.58.115.115 web2.example.com 45.56.67.40 web3.example.com 但是我做ping localhost.example.com我得到这个: PING localhost.example.com (104.200.16.137): 56 data bytes 64 bytes from […]
尝试在NGINX中将简单的子域redirect到URI / URLpath。 在这一点上,我想让nginx.somedomain.com永久redirect到nginx.somedomain.com/sample/redirection.html。 下面的configuration我在nginx.conf文件中,但不工作。 我已经重新启动服务器,但仍然没有去。 具体来说,它错误并在nginx.conf文件中显示这是无效的。 这应该去哪里,这也是正确的? server { server_name nginx.somedomain.com; rewrite ^(.*) http://nginx.somedomain.com/sample/redirection.html permanent; } 感谢您的帮助!
这是在CentOS 7.2中通过PHP-FPM使用nginx 1.6.3和PHP 7.0.7。 我已经运行了很多使用LAMP的站点,并且一直在尝试切换到LEMP,但是一直持续不断的问题是,即使我在PHP中设置了不同的状态,我的页面处理程序仍然在状态中显示404错误。 就好像nginx完全忽略了从PHP发送的404错误页面的头文件。 /etc/nginx/nginx.conf看起来像: user web web; worker_processes auto; error_log /var/web/Logs/WebServer/nginx-error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/web/Logs/WebServer/nginx-access.log main; fastcgi_buffers 8 1024k; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; […]
我有一个nginx设置的服务器。 我希望它响应域testhero.in.th 。 所以在configuration文件中,在我的服务器块中,我设置了server_name testhero.in.th 。 我试图通过域访问该网站,我得到服务器花了很长时间来回应 。 所以我使用dig来查看域是否指向我的服务器。 我得到一个指向我的服务器的logging。 该IP是188.166.198.107 。 然后我进入地址栏的IP,然后我可以访问该网站。 为了确保,我尾巴的Nginx的访问日志。 当我尝试使用ip访问服务器时,我看到日志,但是当我尝试通过域访问时,我不知道。 我应该采取哪些措施来找出为什么我无法通过我的域名访问该网站?
我有两个不同的域 – thisdomain.com和portal.thisdomain.com 。 但只有一个面向公众的IP地址。 每个域都有自己的SSL证书,但共享相同的中间CA. 使用相同的IP地址(并且NGINX HTTP服务器支持SNI),我想为网站URL的不同部分提供一套不同的TLSv1.2-only密码/散列/ MAC。 NGINX是否能够支持不同的密码/哈希/ MAC: 同一个域的不同子域? 和/或 不同的同一个域的URL子目录? 而使用相同的IP地址? 在不同域的例子中, https://portal.thisdomain.com/能够通过https://thisdomain.com拥有自己的密码/哈希/ MAC设置? 在不同的URL 子目录的例子中, https://thisdomain.com/portal可以通过https://thisdomain.com/拥有自己的密码/哈希/ MAC?
我试图从我的服务器获取数据,但如果我尝试从localhost/my/api它给400,但如果我尝试从localhost/my/api它给我需要的内容。 我正在使用nginx,这里是服务器的configuration文件 server { listen 80; server_name localhost 54.149.242.144; access_log /var/log/nginx/myapp.log; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/myapp; } location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 另外如果我做一个netstat我得到这个服务器 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8080/nginx 为什么它只能从本地主机给我正确的内容,并从0.0.0.0地址给我400的? 也是这样做,所以我不能从外部机器访问API。 最后,我使用gunicorn作为后端服务器,并使用nginx来反向代理gunicorn。
我必须在nginx中结合两个规则: (1)如果主机不是www.host.deredirect到www.host.de (2)如果协议是HTTPredirect到https 我目前的解决scheme首先更改为www,并在下一个请求更改为https。 这意味着我有多个redirect。 我试图把它减less到一个redirect。 我的规则: server_name .host.de; set $wanted_domain_name www.host.de; if ($http_host != $wanted_domain_name) { rewrite ^(.*)$ $scheme://$wanted_domain_name$1; } if ($scheme != "https") { rewrite ^ https://$host$uri permanent; } 我试图通过使用variables重写参数来解决这个问题(因此我要求在一个variables中存储正则expression式)。 我如何优化redirect,这样我就不会有两个客户端redirect?
我在Ubuntu 14.04上使用nginx(1.4.6-1ubuntu3.4)。 当有人访问一个页面,例如http://mymaindomain.com/page1 ,我想重写它包含www子域。 所以如果有人访问了以前的URL,重写的URL将是http://www.mymaindomain.com/page1 。 所以我添加了一个“服务器”指令: user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { … } server { server_name mymaindomain.com; rewrite ^ http://www.mymaindomain.com$request_uri permanent; } 到我的/etc/nginx/nginx.conf文件的末尾。 但重新启动我的服务器后,我得到的错误: 2016/11/04 22:12:33 [emerg] 1063#0: "server" directive is not allowed here in /etc/nginx/nginx.conf:75 什么是正确的方法来设置我的nginx服务器来正确地重写我的url?
我正在尝试将http://www.example.com:88的请求重写为https://www.example.com:4430 目前,我被困在非标准的端口。 这是我的configuration: upstream pool { server 127.0.0.1:5001; server 127.0.0.1:5002; } server { listen 88; listen 4430 default ssl; if ($ssl_protocol = "") { rewrite ^ https://$server_name:4430/$uri permanent; # this also fails with https://www.example.com/:4430 #rewrite ^/(.*)$ https://$host:4430/$1 permanent; #rewrite ^ https://www.example.com:4430/ permanent; } location / { proxy_pass http://pool; proxy_set_header Host $host; proxy_redirect off; proxy_set_header X-Forwarded-Proto […]