Binde Inhalte in eine Domain von einer anderen (sub)Domain seokonform ein mittels nginx
von Andreas
Hauptdomain Nginx Einstellungen
wir arbeiten mit proxy_pass und sub_filter um an die Daten einer anderen (Sub-)Domain zu gelangen und seokonform darzustellen
server {
listen *:80;
server_name domain.de www.domain.de;
listen *:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/domain.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.de/privkey.pem;
root /var/www/domain.de/web/public;
index index.php index.html index.htm;
# Proxy Header Limits erhöhen
proxy_buffer_size 16k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
# Weiterleitung von HTTP zu HTTPS
if ($ssl_protocol = "") {
rewrite ^ https://domain.de$request_uri? permanent;
}
#error_log /var/log/ispconfig/httpd/domain.de/error.log debug;
error_log /var/log/ispconfig/httpd/domain.de/error.log;
access_log /var/log/ispconfig/httpd/domain.de/access.log combined;
# ....
# Blog
location ^~ /blog {
# Reverse Proxy zur Ziel-Domain
# ohne / am Ende ,dann geht es durch location ^~ /blog auf https://blog.domain.de/blog/ welche als Ziel erreichbar sein muss dort auch als /blog/ mit / am Ende!
proxy_pass https://blog.domain.de;
#proxy_pass http://unix:/var/lib/php5-fpm/web70.sock;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
# Cookie-Manipulation
#proxy_cookie_path / /blog/;
#proxy_cookie_domain blog.contao.domain.de domain.de;
# Dynamische Link-Umschreibung
sub_filter 'https://domain.de/files/assets/' 'https://domain.de/assets/';
sub_filter 'https://blog.contao.domain.de/' 'https://domain.de/blog/';
#für assets
#sub_filter 'https://domain.de/blog/files/assets/' 'https://domain.de/assets/';
sub_filter_once off;
#Umschreiben mehrerer Vorkommen in einer Antwort
##sub_filter_types text/html text/css text/javascript application/css application/x-javascript;
sub_filter_types *;
#Nur HTML-Inhalte,css,js umschreiben
# Entferne Host-Header der Ziel-Domain
proxy_set_header Host blog.contao.domain.de;
#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_set_header X-Forwarded-Proto $scheme;
# Cache und Timeout-Einstellungen
#proxy_cache_bypass $http_upgrade;
#proxy_connect_timeout 60s;
#proxy_send_timeout 60s;
#proxy_read_timeout 60s;
}
# Genereller PHP-Handler
# ...
}
