Articles of 虚拟主机

阻止到Apache Web服务器的直接IP连接

我需要弄清楚如何阻止直接访问我的网站的IP。 例如:我希望当人们在浏览器中input我的IP地址1.2.3.4时不起作用,但是当他们inputwww.example.com它确实起作用。 我使用Apache 2.4.9 ,我的网站使用WampServer 。 我在这里试过了一些老问题的解决办法,但是没有一个能为我工作。 我已经尝试将虚拟主机的东西粘贴到vhosts.conf中,但是我无法正确地完成,而且我试图用htaccess文件重写东西,但是这也不起作用。

Apache HTTPD:具有代理和目录别名的虚拟主机的URLparsing

以下是我的环境: REST api (django),在端口http://server:8107/api上通过WSGI(mod_wsgi)运行 API网站的静态文件 (我有一些pipe理页面),在一个目录中,说/opt/wsgi/staticfiles/subdomain 运行在pm2 / nodejs上的Web应用程序 (expressjs)在http://server:3002/ 我需要将所有这些在端口80上的虚拟主机下进行分组,如下所示: http://subdomain.server/api :其余的API http://subdomain.server/api/static :API网站所需的静态文件 http://subdomain.server/ :web应用程序 以下是configuration的相关部分: <VirtualHost *:80> ServerName subdomain.server ServerAlias subdomain.server.local Alias /api/static/ /opt/wsgi/staticfiles/subdomain/ <Directory /opt/wsgi/staticfiles/subdomain/ > Order Allow,Deny Allow from All Options -Indexes IndexOptions Charset=UTF-8 </Directory> ProxyPass /api http://127.0.0.1:8107/api ProxyPassReverse /api http://127.0.0.1:8107/api ProxyPass / http://127.0.0.1:3002/ ProxyPassReverse / http://127.0.0.1:3002/ </VirtualHost> 现在,当我尝试访问一个静态资源(比如说/api/static/js/jquery.js )时,我发现URL并不是由Alias指令首先parsing,而是传递给WSGI应用程序( […]

在Debian 8.6虚拟机 – 服务器块(虚拟主机)问题上设置nginx 1.10.1

大家好,问候。 首先感谢您抽出宝贵的时间来回顾并回答我的问题。 非常感谢。 或多或less,我正在使用新的虚拟机(Google Cloud Computing)设置所有设置,并尝试使用Debian,nginx,mariadb,php。 我已经在虚拟机上多次尝试过这种types的设置,但是这次我决定在使用apt-get的时候得到最新版本的nginx(1.10.1)而不是Debian的默认软件包安装nginx而不更新源列表。 (我相信一个就像1.6.3)。 虽然两者之间的差异是最小的,但我注意到的一件事是这个版本的nginx不使用服务器块(Vhosts)的/ sites-enabled /和/ sites-available /文件夹,它直接进入/ etc / nginx / conf.d /文件夹。 没问题,我想。 现在我的情况是我正在工作的网站organiplan点com显示404页面没有find,尽pipe它似乎像我的服务器块和nginx.conf文件安装正确。 我将在下面包括。 服务器块 server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/html/organiplan.com/public_html; index index.php index.html index.htm; server_name organiplan.com www.organiplan.com; client_max_body_size 1024m; location / { try_files $uri $uri/ /index.php?q=$request_uri; } error_page 404 /404.html; error_page […]

一个虚拟主机的HTTPS失败

好吧,这听起来像是一个奇怪的问题…我很犹豫,甚至在这里发布,因为我不能很好地处理如何描述它,更不用说从哪里开始寻找解决scheme。 我有一个站点(Fedora 24,标准的LAMP堆栈,运行在Amazon EC2上),当通过HTTPS请求时,最近开始响应空白页面。 所以举个例子,如果你浏览http://example.com/coolscript.php,它可以正常工作,但是http://example.com/coolscript.php返回一个空白页面。 Web服务器日志显示两者都是HTTP 200,但HTTPS版本没有返回数据(后者,如下所示): 1.2.3.4 – – [22/Dec/2016:16:19:39 +0000] "GET /coolscript.php HTTP/1.1" 200 9069 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" 1.2.3.4 – – [22/Dec/2016:16:19:25 +0000] "GET /coolscript.php HTTP/1.1" 200 – "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" 我曾经尝试过不同的浏览器,个人电脑,networking等,所有的回应都是空白的。 你可能会觉得我有些东西与Apache中的虚拟主机定义混淆了,但是访问简单的文件(甚至是PHP脚本)可以正常工作。 该证书是有效的,好去。 在同一台服务器上的其他支持HTTPS的站点可以很好地使用不同的证书,甚至使用相同证书的虚拟主机别名也能正常工作。 […]

HTTPSredirect失败的一些url,而不是其他人

当URL是以下任何一个时,从HTTP到HTTPS的redirect都正确发生: http://example.com >> https://example.com [确定] http://www.example.com >> https://example.com [确定] http://www.example.com/login >> https://example.com/login [确定] 但是,如果URL如下所示,redirect到HTTPS将失败 : http://example.com/login >>错误(请参见截图) 请告知如何解决。 代码和configuration如下。 先谢谢你… 其他详情: Ubuntu 16.04 Apache 2.4 mod_rewrite已启用 Laravel 5.3 清除浏览器caching .htaccess文件 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Allow Blog in Sub-Directory RewriteCond $1 !^(blog) #Redirect to non-WWW RewriteCond %{HTTP_HOST} ^www.example.com$ RewriteRule ^(.*) […]

Apache不听指定的端口

我正在尝试build立一个Nginx + Apache与PHP模块configuration。 它使用这样的configuration在Debian 6上工作: <VirtualHost 127.0.0.1:9002 > ServerName mysite.com AddDefaultCharset UTF-8 AssignUserID username username CustomLog /var/www/httpd-logs/mysite.com.access.log combined DocumentRoot /var/www/username/data/www/mysite.com ErrorLog /var/www/httpd-logs/mysite.com.error.log AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml AddType application/x-httpd-php-source .phps php_admin_value open_basedir "/var/www/username/data:." php_admin_value upload_tmp_dir "/var/www/username/data/mod-tmp" php_admin_value session.save_path "/var/www/username/data/mod-tmp" </VirtualHost> NameVirtualHost 127.0.0.1:9002 <Directory /var/www/username/data/www/mysite.com> Options -ExecCGI -Includes php_admin_value open_basedir "/var/www/username/data:." php_admin_flag engine on […]

Apache在dynamic主机上重写为nginx

我做了一些阅读,我找不到我的问题的答案,因为它有一个关键组成部分是不同于大多数情况下。 它和其他故事一样:我需要将.htaccess迁移到nginxconfiguration中,如果不是这样,nginx服务器设置为使用dynamic主机: server { listen 80; server_name ~^(www\.)?(?<sname>.+?).server.company.com$; root /var/www/$sname/current/public; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~* \.(gif|png|bmp|ico|flv|swf|exe|html|htm|txt|css|js) { add_header Cache-Control public; add_header Cache-Control must-revalidate; expires 7d; } location ~ \.php$ { fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; include fastcgi_params; fastcgi_param DOCUMENT_ROOT $realpath_root; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; } location ~ /\.ht […]

为什么nginx服务http2,还是它?

一直试图让我的nginx服务器上的http2,我对一些事情感到困惑。 我环顾了这里和networking周围,但是我没有find我正在寻找的东西,或者是在它还没有被“释放”时使用过时的信息来回答。 我有工作nginx服务器,使用虚拟主机。 它有http_v2模块 me@server:/etc/nginx$ sudo nginx -V | grep http2 nginx version: nginx/1.10.3 built with OpenSSL 1.1.0f 25 May 2017 TLS SNI support enabled configure arguments: –with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-2tpxfc/nginx-1.10.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' –with-ld-opt='-Wl,-z,relro -Wl,-z,now' –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 –modules-path=/usr/lib/nginx/modules –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 […]

Apache似乎忽略了80端口的虚拟主机

这工作(或似乎是)今天早些时候,但我最近重新启动我的服务器,现在Apache似乎不承认我的端口80虚拟主机。 我的网站来自/var/www/example.com/public_html,端口80 应该redirect到HTTPS。 在我的服务器重新启动之前,这是工作; 现在它不redirect,并提供/ var / www / html中的默认内容。 我不确定服务器重新启动后是否需要启动某些进程或服务? 该网站已启用,端口443虚拟主机正在按预期工作。 Apache版本是2.4.27,OS是Ubuntu 17.10。 这是我的conf文件在/etc/apache2/sites-available/example.com.conf。 LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule ssl_module modules/mod_ssl.so <VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> </VirtualHost> <VirtualHost *:443> SSLEngine On SSLCertificateKeyFile /etc/ssl/private/example_com.key SSLCertificateFile /etc/ssl/certs/example_com.crt SSLCertificateChainFile /etc/ssl/certs/example_com.ca-bundle […]

Apache mod_rewrite,使用RewriteCond中的当前URL

我在Apache VirtualHostconfiguration中有几个RewriteRules。 我想能够testing当前的URL(在重写之前)针对某些条件。 问题在于variables%REQUEST_URI在处理开始时被设置,并且在每个规则之后都不会改变。 关于这些variables的文档很less。 有没有办法使用RewriteCond来testing当前的url? 我已经启用了重写日志,很明显,即使在第一个RewriteRule被匹配并重写之后,%REQUEST_URI仍然被设置为“/” #Map '/' and '' to '/home' RewriteRule ^/?$ /home #Check for cached page RewriteCond %{DOCUMENT_ROOT}/system/cache%{REQUEST_URI}.html -f RewriteRule ^(.+)$ /system/cache/$1.html [QSA,L] 有没有简单的方法来完成这个? 编辑:这是从RewriteLog摘录,我不认为是一个内部的子请求正在发生。 (3) applying pattern '^/?$' to uri '/' (2) rewrite '/' -> '/home' (3) applying pattern '^([^.]+)$' to uri '/home' (4) RewriteCond: input='/var/www/vhosts/example.com/subdomains/demo/rails/public/system/cache/.html' pattern='-f' => not-matched (3) […]