NGINX Proxy from New Domain to Old Domain

I am currently running Graylog 3.2.6 behind an NGINX proxy and everything seems fine using this configuration:

location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-Server $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Graylog-Server-URL https://$server_name/;
      proxy_pass       http://127.0.0.1:9000;
}

I now have a new domain and I would like to proxy from the new domain to the old domain using another NGINX proxy. I seem to be having problems getting this to work and wondered if any one had tried this before?

I would be using a subfolder as the location on the new domain as I need to redirect the proxy to a few other web applications:

New domain is https://my.newdomain.uk/graylog

location /graylog {
  proxy_ssl_server_name on;
  proxy_ssl_trusted_certificate /etc/nginx/conf.d/trusted_ca_cert.pem;
  proxy_set_header Host \$http_host;
  proxy_set_header X-Forwarded-Host \$host;
  proxy_set_header X-Forwarded-Server \$host;
  proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
  proxy_set_header X-Graylog-Server-URL https://\$server_name/graylog/;
  rewrite          ^/graylog/(.*)$  /\$1  break;
  proxy_pass https://graylog.olddomain.uk/;
}

Config taken from the Graylog docs at: Web interface — Graylog 3.2.0 documentation

Looking at the developer network tools its looks like I am getting through to “graylog.olddomain.uk” for some of the calls but some are failing like config.js,

graylog	200	document	Other	2.1 kB	38 ms	
config.js	(failed)	script	graylog	0 B	26.67 s	
vendor.5452e7a2fdfb6282da0a.js	(failed)	script	graylog	0 B	26.97 s	
polyfill.8db32af0c31b8447f8a4.js	200	script	graylog	(memory cache)	0 ms	
builtins.8db32af0c31b8447f8a4.js	200	script	graylog	(memory cache)	0 ms	
plugin.org.graylog.plugins.threatintel.ThreatIntelPlugin.65246bb8027ae212c591.js	(failed)	script	graylog	0 B	26.97 s	
plugin.org.graylog.plugins.collector.CollectorPlugin.8abec7f8843fccf91256.js	(failed)	script	graylog	0 B	45.71 s	
plugin.org.graylog.integrations.IntegrationsPlugin.84791d9e764ff1198f4a.js	(failed)	script	graylog	0 B	45.98 s	
plugin.org.graylog.aws.AWSPlugin.98d75e309aea282eb4fb.js	200	script	graylog	(memory cache)	0 ms	
plugin.com.sportalliance.graylog.plugins.slacknoti…n.SlackNotificationPlugin.ee93dacee86e841efd4c.js	200	script	graylog	(memory cache)	0 ms	
app.8db32af0c31b8447f8a4.js	(failed)	script	graylog	0 B	45.99 s	Scriptpolyfill.8db32af0c31b8447f8a4.js	200	script	graylog	(disk cache)	3 ms	
builtins.8db32af0c31b8447f8a4.js	200	script	graylog	(disk cache)	37 ms	
plugin.org.graylog.aws.AWSPlugin.98d75e309aea282eb4fb.js	200	script	graylog	(disk cache)	92 ms	
plugin.com.sportalliance.graylog.plugins.slacknoti…n.SlackNotificationPlugin.ee93dacee86e841efd4c.js	200	script	graylog	(disk cache)	3 ms	
favicon.png	(failed)		Other	0 B	29.49 s

Looking at the config.js initiator tab in dev tools:

    https://my.newdomain.uk/graylog
    https://graylog.olddomain.uk/config.js

Hello,
I have not configured Nginx to be used between to domains, but I do have a question on the configuration as shown below.

Was this a typo? or you not using port 9000 in your proxy config?

No this is not a typo, two NGINX proxies are in place. So the config relating to port 9000 is in the proxy currently in place for the old domain (see location block one above).

So after a lot of attempts at getting a sub path working I had to give up and set this up on root. This required splitting all the configurations up into separate sites.

location / {
  proxy_ssl_server_name on;
  proxy_ssl_trusted_certificate /etc/nginx/conf.d/trusted_ca_cert.pem;
  proxy_set_header Host $http_host;
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Graylog-Server-URL https://$server_name;
  proxy_pass https://graylog.olddomain.uk/;
  proxy_redirect off;
  sub_filter_types *;
  sub_filter_once off;
  sub_filter_last_modified on;
  sub_filter "https://\$proxy_host" "$scheme://$host";
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.