I currently have two enabled site configurations in nginx, let us call them old-site.example
and new-site.example
. There is no other site configuration active.
old-site.example
should 301-redirect to new-site.example
. This currently works well as long as the old-site.example
configuration is alone. After adding the new-site.example
configuration file, it does not redirect anymore.
oldsite.conf
:
server {
listen 80;
server_name *.old-site.example;
rewrite_log on;
location / {
return 301 http://www.new-site.example$request_uri;
}
}
newsite.conf
:
server {
listen 80;
server_name www.new-site.example;
charset utf-8;
location / {
#forward to application server
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
}
other configuration details:
- JBoss AS7 as application server running behind Nginx 1.5.1