Welcome! Log In Create A New Profile

Advanced

Serving location after redirect from other domain

Posted by phloks 
Serving location after redirect from other domain
February 25, 2016 11:35AM
Hi,

I have a problem, and am unable to get what I want, even after many searches here and in Google.
Don't know if it is even possible.

I recently got a domainname ((www.)hanslammerts.nl). On this domainname I have a redirectservice that redirects every call to this domain to hanslammerts.servebeer.com.
On this server I have nginx running that serves several locations. Going directly to e.g. hanslammerts.servebeer.com/phpmyadmin works perfectly.
If I go to hanslammerts.nl/phpmyadmin, it does not work. I am being redirected to / instead of /phpmyadmin.

The first (and only) thing I do on the server definition for port 80, is to redirect everything to ssl.
Could this be my problem ?

My config for the site looks like this:

upstream php-handler {
#server 127.0.0.1:9000;
server unix:/var/run/php5-fpm.sock;
}

server {
listen 80;
server_name hanslammerts.servebeer.com;
# enforce https
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name hanslammerts.servebeer.com;

ssl_certificate /etc/letsencrypt/live/hanslammerts.servebeer.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/hanslammerts.servebeer.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

# Path to the root of your installation
root /var/www/html/;

# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";

location ~ /.well-known {
allow all;
}

##################
# GateOne #
##################

location /gateone/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://localhost:1443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

##################
# phpmyadmin #
##################

location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}

location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}

##################
# PHP stuff #
##################

location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
}

##################
# eGroupware #
##################

location /egroupware {
index index.php;
location ~ ^/egroupware/(.+\.php)$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}

location /weewx/ {
index index.html;
}
}

In short:
All I want to achieve is for the URLs http://hanslammerts.nl/egroupware, http://hanslammerts.nl/weewx, etc. to be picked up by nginx running on hanslammerts.servebeer.com, redirect to ssl, and then go to the location of the URI, e.g. egroupware, weewx etc.

Is this at all possible ?
Hope someone can point me in the right direction.

Thank you,
Hans
Re: Serving location after redirect from other domain
February 26, 2016 12:04PM
Hello,

I'm not sure what kind of redirect service you are using, but I see frames using curl:

# curl hanslammerts.nl/phpmyadmin
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name='keywords' content="">
<meta name='description' content="">
</head>
<frameset rows="100%,*" frameborder="NO" border="0" framespacing="0">
<frame name="111" src="http://hanslammerts.servebeer.com/phpmyadmin">
<frame name="222" scrolling="NO" noresize>
<noframes><!-- -->
</noframes>
</frameset>
<body>
</body>
</html>

You might be better off using a "real" redirect, like a 301 which includes the URI, on the redirecting server. Since that server uses Apache, something like this in a .htaccess file might work:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^hanslammerts.nl [NC,OR]
RewriteCond %{HTTP_HOST} ^www. hanslammerts.nl [NC]
RewriteRule ^(.*)$ https://hanslammerts.servebeer.com/$1 [L,R=301,NC]

--
Jim Ohlstein
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 325
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