I am trying to integrate wordpress into my site which is running on Nodejs server with Apache Httpd port forwarding enabled to forward all the request from 80 port to Nodejs port 9000. I have installed wordpress into Apache httpd /www/blog folder.
Now, i want to edit my httpd.conf so that all my requests coming from client should still be forwarded to nodejs server except my blog.example.com calls which should not be proxy forwarded and they should point to /www/blog folder. Is this possible ?
Here is the Virtualhost code from httpd.conf :-
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://localhost:9000/
ProxyPassReverse / http://localhost:9000/
ServerName example.com
</VirtualHost>
Any help would be appreciated.
This worked for me. Might be of some help for others.
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.example\.com
RewriteRule ^(.*)$ http://www\.example\.com/blog/$1 [L]
ProxyPreserveHost On
ProxyPass /blog !
ProxyPass / http://localhost:9000/
ProxyPassReverse / http://localhost:9000/
ServerName example.com
</VirtualHost>
Related
I have been looking around for an answer to my problem for a while and have read various other answers without coming across one that works for me.
The problem I am trying to solve involves redirecting access to a WordPress site installed on an Apache server. The WordPress site is one of many installed as part of a WordPress Network installation and the site is setup on the domain https://www.mysite1.co.uk.
It is also necessary to access the site using a number of server aliases, which are to be redirected to the root domain. I have created the additional domains as server aliases in the Apache configuration, and have set redirects to ensure that if one of the aliases is entered then it should be redirected to the root domain.
<VirtualHost *:80>
ServerName www.mysite1.co.uk
ServerAlias mysite1.co.uk www.mysite2.co.uk mysite2.co.uk
...
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)\.?$ [NC]
RewriteRule ^ https://www.mysite1.co.uk%{REQUEST_URI} [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerName www.mysite1.co.uk
ServerAlias mysite1.co.uk www.mysite2.co.uk mysite2.co.uk
...
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)\.?$ [NC]
RewriteRule ^ https://www.mysite1.co.uk%{REQUEST_URI} [R=301,L]
SSLEngine On
SSLCertificateFile "certs/mysite1.co.uk.crt"
SSLCertificateKeyFile "certs/mysite1.co.uk.key"
</VirtualHost>
This configuration works whenever the user enters one of the aliases using http, they are redirected to https://www.mysite1.co.uk/. However, if they enter the aliases using https, instead of being redirected to https://www.mysite1.co.uk/, they are not being redirected at all.
Have I missed something in the configuration, or do I need to separate the https configuration and add the aliases into their own virtual host to do the redirect.
The sites are hosted on CentOS 7.9.2009 and running Apache 2.4.6.
If I got it correctly, you're trying to redirect every known domain reaching your apache to just one domain and when the connection comes as HTTP you want to redirect it to HTTPS.
To keep the configuration simple, I would create 3 different virtual hosts:
The first one will listen on http and include every domain you want to redirect (including the main one becuase it's listening on http). This virtualhost will redirect everything to the main domain over https:
<VirtualHost *:80>
ServerName main.site.com
ServerAlias mysite.example.com
ServerAlias another.site.com
Redirect permanent / https://main.site.com/
</VirtualHost>
The second one will listen on https port and includes all the domains but the main one and redirect it to your primary domain (it's like the previous one except it doesn't include the main domain)
<VirtualHost *:443>
ServerName mysite.example.com
ServerAlias another.site.com
Redirect permanent / https://main.site.com/
...
SSLEngine On
...
</VirtualHost>
In the end, the main one will just listen on https and will include only the main domain:
<VirtualHost *:443>
ServerName main.site.com
...
SSLEngine On
...
</VirtualHost>
This way, the only virtualhost requiring configuretiona (document root, locations, etc.) is the last one.
I want deploy my app with shiny using command shiny::runApp(). My question is if it's possible to do this use https instead of http (I can't install shiny server).
Now I run in this mode: shiny::runApp("app.R", port=3090, host="myipaddress"). I have a domain that point in the ip address and if I write in browser: http://mydomain:3090 works correctly.
My problem is that I can't find any mode to switch from http://mydomain:3090 to https://mydomain:3090.
Any help is appreciated
As suggest Sergio Romero I have used reverse proxy on apache on port 443 and handle ssl certificate.
I followed this guide to setting configuration of Virtual Host on Apache
<VirtualHost *:443>
ServerName mydomainname
<Proxy *>
Allow from mydomainname
</Proxy>
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /(.*) ws://mydomainname:myport/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /(.*) http://mydomainname:myport/$1 [P,L]
ProxyPass / http://mydomainname:myport/
ProxyPassReverse / http://mydomainname:myport/
ProxyRequests Off
## SSL directives
SSLEngine on
SSLCertificateFile "path_to_cert.pem"
SSLCertificateKeyFile "path_to_privkey.pem"
SSLCertificateChainFile "path_to_fullchain.pem"
</VirtualHost>
When I execute my Blazor app on localhost everything is fine. When I upload the compiled code to my final server, the app works but all CSS/JS are missing.
I use Centos 7 + Apache in reverse proxy mode.
My CNF:
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
<VirtualHost *:80>
# Your domain name
ServerName 192.168.5.69
ProxyPreserveHost On
# The IP and port of the JBoss Enterprise Application Platform
# These represent the default values, if your HTTPD is on the same host
# as your JBoss Enterprise Application Platform managed domain or server
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
# The location of the HTML files, and access control information
DocumentRoot /var/www/html
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
RewriteRule /(.*) ws://127.0.0.1:5000/$1 [P]
<Directory /var/www/html>
Options -Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
On Chrome console I see:
Siti:12 GET http://192.168.5.69/js/JavaScriptInterop.js net::ERR_ABORTED 404 (Not Found)
Siti:11 GET http://192.168.5.69/css/site.css net::ERR_ABORTED 404 (Not Found)
Siti:10 GET http://192.168.5.69/css/font-awesome/font-awesome.min.css net::ERR_ABORTED 404 (Not Found)```
I'm using apache 2.2.15, in a virtual machine over CentOS 6, I have a symfony proyect working here and my boss want to load a wordpress website in the same server on a subdomain.
Subdomain is not working, I've tried a lot of configurations, this is the last one used:
mysite.cl.conf (in /etc/httpd/conf.d folder)
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/symfonyProyect/web
ServerName mysite.cl
ServerAlias mysite.cl
ErrorLog /var/log/httpd/symfonyProyect_error.log
CustomLog /var/log/httpd/symfonyProyect_access.log combined
<Location />
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /app.php [L]
</IfModule>
DirectoryIndex app.php
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerName mysubdomain.mysite.cl
DocumentRoot /var/www/html/mysubdomain
<Directory /var/www/html/mysubdomain>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/mysubdomain_error.log
CustomLog /var/log/httpd/mysubdomain_access.log combined
</VirtualHost>
my hosts file (in /etc folder)
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
myip mysite.cl mysubdomain.mysite.cl
and my hosts.conf
multi on
when I try mysite.cl it shows the symfony website, but when I try mysubdomain.mysite.cl, it gives me the "This site can't be reached" or "ERR_NAME_NOT_RESOLVED".
The if I delete the first VirtualHost block, it showsme the wordpress website ( even using ServerName mysubdomain.mysite.cl).
Am I missing some configuration or something??
The error you are getting is a DNS one not one from Apache. You need to modify the hosts file on same machine you are trying to browse to mysubdomain.mysite.cl.
Open a command prompt/shell on the machine you are running your browser on and just run ping mysubdomain.mysite.cl if it works your browsing should work too. If you get a message something like ping: unknown host mysubdomain.mysite.cl (Linux) or Ping request could not find host mysubdomain.mysite.cl (Windows). then simply edit the hosts file on that system or get a DNS entry added to your name server.
Simply editing /etc/hosts on the server that Apache runs on doesn't cause all other hosts to be able to resolve a hostname to an IP address.
I've installed varnish-ban-manager (https://github.com/dot2code/varnish-bans-manager) and I'm currently configuring it's DNS name.
The thing is that I've set in Route53 (DNS service in AWS) to use name http:// purge.domain.com / pointing to http:// varnish_server_name.com/. The thing is, if I test with http :// purge.domain .com:9000/ it works normally, but using http: //purge.domain.com/ will send me a "your request cannot be processed" (in a varnish error screen).
Any ideas why this could be happening? I've test this with the ip address of this vm and works perfectly too..
Here's the vhost config file:
<VirtualHost *:80>
ServerName purge.domain.com
ServerAlias purge.domain.com
ProxyPass / http://varnish_server.domain:9200/
ProxyPassReverse / http://purge.domain.com/
# Logging
ErrorLog logs/server-error_log
CustomLog logs/server-access_log combined
</VirtualHost>
Note: i've replaced my real domain for "domain" just in case.
Thanks guys!!
Solved. I've added some lines to vhost:
ServerName http:// purge.comain.com
ProxyPass / http:// varnish_server:9000/
ProxyPassReverse / http:// varnish_server:9000/
ErrorLog logs/purge. cloud-turner.com.ar-error_log
CustomLog logs/purge. cloud-turner.com.ar-access_log combined
And added proxy.conf (/etc/httpd/conf.d/) with this line
ProxyPreserveHost on
And that's it!