1

I'm trying to

  • redirect all traffic from www.example.com and example.com to old-www.website.com

  • proxy all traffic from example.com/forum (and www) to forum server @ 192.168.100.100

I've tried the following config but it keeps returning me to my old website When I remove the location / the forum is not loading and I'm getting 404's since the server is trying to load files @ example.com/ instead of example.com/forum

server { listen 80; server_name www.example.com example.com; location /forum/ { proxy_pass http://192.168.100.100/; proxy_redirect off; proxy_set_header Host $host; } location / { return 302 $scheme://www.old-site.com; } } 

how can I fix this?

2 Answers 2

1

The issue is the extra / in your proxy_pass statement. This causes nginx to use / as the URI with your forum always.

Try this:

location ~ /forum(/.+)? { proxy_pass http://192.168.100.100$1; proxy_redirect off; proxy_set_header Host $host; } 

Here I assume that you want the URL http://www.example.com/forum/something get proxied to http://192.168.100.100/something. Without the regular expression match and $1 in the proxy_pass, it would proxy to http://192.168.100.100/forum/something.

-1

Try this, Here’s a very simple example that redirects clients to a new domain name:

server { listen 80; listen 443 ssl; server_name www.old-name.com; return 301 $scheme://www.new-name.com$request_uri; } 
3
  • I'm using nginx, my main focus is on solving the forum url/proxy issue how can I solve that? Commented Nov 10, 2016 at 11:48
  • try new answer, it may help you Commented Nov 10, 2016 at 12:00
  • I need to proxy the forum server on any url starting /forum Commented Nov 10, 2016 at 12:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.