How to proxy all requests to localhost using nginx and plesk? - nginx

I need to deploy a Nuxt.js SSR web application on a centos server. Plesk control panel is already on the server so I need to proxy all requests from example.com to localhost:3000 except plesk control panel which is example.com:8443 and an API URL which is example.com/api/v1 (API is in the WWW folder). The Web server used is nginx.
I tried to use nginx proxy mode, but then I can't get access to API or plesk control panel anymore.
I expect to have 3 vhosts on one IP:
www.example.com for web application
www.example.com:8443 for plesk control panel
www.example.com/api/v1 for API

For those with the same problem. this is how i solved it:
go to Plesk control panel/ websites and domain/ Apache and Nginx settings
in Additional Apache directives section you can add your apache code:
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
<Location /API/>
ProxyPass !
</Location>

Related

Redirect on HAProxy

I'm trying to replicate the following configuration made in apache in HAProxy, but so far without success.
<VirtualHost *:80>
ProxyPreserveHost On
ServerName alpha.app.int
ProxyPass / http://127.0.0.1:8080/app/
ProxyPassReverse / http://127.0.0.1:8080/app/
</VirtualHost>
What I'm trying to do is when the address 'alpha.app.int' is accessed, HAProxy automatically directs all requests for my application in JBoss that is listening on '127.0.0.1:8080/app/', but when I try to access through the url previously mentioned I end up falling on the configuration screen of JBoss and not in my application, I can only see it by accessing 'alpha.app.int/app/'. Does anyone have any suggestions on how to do this?
HAProxy Settings:
frontend app
bind *:80
mode http
default_backend frontend app
backend app
mode http
option forwardfor
server alpha 127.0.0.1:8080/app
You can try that :
frontend app
bind *:80
acl path_root path /
redirect location https://www.example.com/app/ if path_root
default_backend app
backend app
mode http
option forwardfor
server alpha 127.0.0.1:8080

Wordpress container behind Apache2 host can't serve static files

I have a Docker container with wordpress:latest in a host which has Apache 2.4 installed.
I added the lines below to my Apache configuration file, inside the vhost group:
ProxyPass http://localhost:8010
ProxyPassReverse http://localhost:8010
When I try to access my URL I can reach wordpress homepage, however all static files point to localhost so my layout doesn't work.
What am I missing? Some setup at Apache? Wordpress itself?
Apache modules are already enabled.
Edit 1:
Forgot to mention: this piece of configuration is inside a Location directive, which is inside a vhost directive.
<VirtualHost *:80>
...
<Location /usa>
RequestHeader set X-Is-Reverse=Proxy true
RequestHeader set X-Original-Host mysite.com.br
ProxyPass http://localhost:8010
ProxyPreserveHost On
ProxyPassReverse http://localhost:8010
</Location>
...
</VirtualHost>
Check that the Site URL setting in wordpress matches the URL your clients are calling.
This is the documentation on how to change the site URL in wordpress: https://codex.wordpress.org/Changing_The_Site_URL
If you proxy pass to your backend like that, requests coming into your container will be sent with the Host header set to localhost. Apparently, the WordPress container takes care of the host that has been set in order to generate static assets links. Try setting the following proxy option:
ProxyPreserveHost On
Just after the ProxyPass configuration line.
This options forward the Host HTTP header coming from the client over to the proxy connection. This way the backend will understand which public URL it's been called from and asset links should be correct.
Edit.
If you can't use the ProxyPreserveHost Directive you could try and directly set the Host header using:
RequestHeader set Host "your.host.name"

My website is showing apache test page

I created website on Amazon Web Server. I route my ip to my domain using ROUTE 53 service. but now my website is showing APACHE TEST PAGE rather then content while if i enter my ip address/wordpress it's working properly.
Any solution please?
maybe you forgot to add a virtual host in http.conf. Apache restart is needed after this.
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here
</VirtualHost>
https://httpd.apache.org/docs/2.4/vhosts/examples.html

Tor Hidden Service in Plesk

at first sorry for my bad english.
I am using Plesk 12 on my Ubuntu 14.04 Server. In the past i made Tor hidden services for my Domains simply whit the Apache virtual Host Files. And it Works fine.
But now i am using Plesk and now i dont understand hor to make a Exsiting Site reachable over a Hidden Service.
The Site www.example.com is available an the Host settings are :
<VirtualHost 85.214.50.74:7080 >
ServerName "example.com:80"
ServerAlias "www.example.com"
ServerAlias "ipv4.example.com"
ServerAdmin "admin#example.com"
.....
Now i added a second Virtual host :
<VirtualHost 85.214.50.74:8081 >
ServerName "xxxxxxxxxxxxxxxx.onion:80"
ServerAlias "xxxxxxxxxxxxxxxx.onion"
ServerAdmin "admin#xxxxxxxxxxxxxxxx.onion"
......
In the Torrc the Hidden service ist Corret and it generated a kex and a hostname. But if i reload Apache and Nginx and restart Tor, i cant reach the Hidden service.
You shouldn't add the onion site as a virtual host. Apache doesn't serve the requests to the .onion site directly.
Instead, edit your torrc file and add something like:
HiddenServiceDir /var/lib/tor/example.com
HiddenServicePort 8081 127.0.0.1:80
This runs a hidden service on port 8081 that proxies to port 80 on the local host. When you first start Tor it will generate all the keys and the onion address for your site which you can find in /var/lib/tor/example.com/hostname
If you have multiple virtual hosts, you might need to change the HiddenServicePort to use the hostname (or serveralias), but make sure it resolves locally so you're proxying to the local machine.

Is it possible to install rApache on tomcat 6.0?

I've followed all over the instruction provided in the below website.
rApache.net.
mod_R.so is installed and I've configured below things in the sites-enabled folder.
#rApacheInfo
<Location /RApacheInfo>
SetHandler r-info
</Location>
#brew function
<Directory /var/www/brew>
SetHandler r-script
RHandler sys.source
</Directory>
<Directory /var/www/brew>
SetHandler r-script
RHandler brew::brew
DefaultType html
</Directory>
But if i go to localhost:8080/RApacheInfo I get the error HTTP Status 404 - /RApacheInfo.
localhost:8080 gives me apache tomcat welcome note.
As I checked the differed between apache and tomcat from this post. Now I have a doubt whether we'll be able to install it or not.
Please help.
Errr no. Apache tomcat is a server which acts as a container for Java-based 'servlets'. Apache http server is a general server for http requests. What you have listening on port 8080 must be tomcat since you get the tomcat error page.
rApache is specifically a handler for the apache http server. Normally apache http server just sends back a file when a request for /foo.html comes in, but it can be configured to run a program via a handler, which is what rApache is.
You can run apache http server AND tomcat on the same machine, they just have to be listening on different ports. If you try and run them on the same port the second one won't start.
By default apache http server listens on port 80, so if you are running it as root then going to http://localhost/ will get a response if it is running.

Resources