Welcome! Log In Create A New Profile

Advanced

Re: Reverse proxy for multiple domains

Mik J via nginx
May 21, 2018 09:58AM
Hello,

Sorry if I'm asking again a question on the same topic.

I would like to know what is the best practice to setup a web proxy.

I do it like this
- 1 virtual host per application on the reverse proxy and the proxy_pass points to one IP+path
- 1 virtual host (default) for all application on the backend server but one location stanza per application

The problem is that I meet many problems with installation of application: magento, glpi, etc

Is it the correct way to do it ?


On this reverse proxy I have a virtual host which looks like that
server {
listen 80;
server_name application1.org;
access_log /var/log/nginx/application1.org.access.log;
error_log /var/log/nginx/application1.org.error.log;
....
location ^~ / {
proxy_pass        http://10.1.1.10:80/app/application1/;
proxy_redirect    off;
proxy_set_header  Host            $http_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;
}



On the web server behind the proxy I just have one virtual host which is the default one
server {
listen 80 default_server;
server_name _;
index index.html index.htm index.php;
root /var/www/htdocs;
location ^~ /app/application1 {
root /var/www;
index index.php;
location ~ \.php$ {
root          /var/www;
try_files $uri =404;
fastcgi_pass  unix:/run/php-fpm.application1.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
include        fastcgi_params;
}

Le mercredi 30 août 2017 à 19:57:40 UTC+2, Francis Daly <francis@daoine.org> a écrit :

On Sun, Aug 27, 2017 at 11:27:05AM +0000, Mik J via nginx wrote:

Hi there,

> > Thats because the pages are called by the reverse proxy server
> > like http://10.1.1.10:80/app/application1/;and it can't use a FQDN
> > because it's in a private adressing
> Francis: I don't follow that last part.=> I mean that the reverse proxy uses an IP to connect to the backend web server. If it used a fqdn, it has to resolve it, through a dns request

The backend web server can care about the IP:port you connect to, and
the Host: header you send.

You can connect to 10.1.1.10:80 and send a Host: header of "app1" if
you want to. No dns resolution involved.

Anyway, it sounds like you have this part working now; so that's good.


> I still have problems, the site doesn't diplay properly because it can't load a javascript

> The request for the javascript looks like thathttp://application1.org/?wooslider-javascript=load&t=1503832510&ver=1.0.0 HTTP/1.1It arrives on the backend server I see it in the logs (file specified in the stanza location)
> 10.1.1.10 forwarded for IP_CLIENT - - [27/Aug/2017:13:15:12 +0200] "GET /app1/?wooslider-javascript=load&t=1503832510&ver=1.0.0 HTTP/1.1" 404 5 "http://application1.org/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0"

A request for /?some-thing came to nginx; nginx reverse-proxied the request
as /app1/?same-thing. That is all you want nginx to do, so it is working.

If your back-end wordpress handles that request incorrectly, that is a
question for your back-end wordpress configuration.

People on this list who know about wordpress configuration are more
likely to see the question if it is in a new thread with words like
"wordpress" in the Subject: line.

(If the actual question is "why does my browser request /?some-thing
instead of /thing.js ?", that might also be related to the back-end
config.)

> Another question, if I want to set expires header, would it be better to do it on the reverse proxy or on the backend server ?

Again, I'd suggest that people who know about "wordpress" and "expires"
are much more likely to see that question if it is in a thread with an
obvious Subject: line.

Good luck with it!

    f
--
Francis Daly        francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Reverse proxy for multiple domains

Mik J via nginx August 10, 2017 05:18PM

Re: Reverse proxy for multiple domains

Francis Daly August 17, 2017 03:46PM

Re: Reverse proxy for multiple domains

Mik J via nginx August 18, 2017 03:04AM

Re: Reverse proxy for multiple domains

Francis Daly August 20, 2017 04:10PM

Re: Reverse proxy for multiple domains

Mik J via nginx August 27, 2017 07:28AM

Re: Reverse proxy for multiple domains

Francis Daly August 30, 2017 01:58PM

Re: Reverse proxy for multiple domains

Mik J via nginx May 21, 2018 09:58AM

Re: Reverse proxy for multiple domains

Francis Daly May 22, 2018 04:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 234
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready