- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个运行在 website.com:32400/web
的 Plex 服务器。我希望能够使用 Apache 的反向代理功能在 plex.website.com
访问它。以下是我的 /etc/apache2/sites-available/plex.website.com.conf
文件的(相关部分):
<VirtualHost *:80>
ServerName plex.website.com
ProxyRequests off
ProxyPass / http://website.com:32400/web/
ProxyPassReverse / http://website.com:32400/web/
ProxyHTMLURLMap http://website.com:32400/web http://plex.website.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
此设置部分有效;也就是说,如果我访问 plex.website.com/index.html
,那么我将获得与访问 website.com:32400/web/index 时完全相同的 HTML .html
。然而,除此之外,其他一切似乎都是 404(即 CSS 和 JavaScript)。例如,http://website.com:32400/web/img/desktop/ios/icon-iphone.png
加载正常,但 http://plex.website.com/web/img/desktop/ios/icon-iphone.png
产生 404 错误。
虽然我可以直接访问 web
目录中的任何内容,例如加载良好的 plex.website.com/favicon.ico
。很明显,这是一个专门针对映射子域的问题。
已启用所有必要的 Apache 模块。
我不太确定我将如何开始尝试解决这个问题。
编辑:我刚刚意识到它是 404'ing 的原因是它仍然包含 URL 的 web
部分,而这是不应该的。在我给出的示例中,http://plex.website.com/web/img/desktop/ios/icon-iphone.png
是它试图访问的位置 - 但这应该是 http://plex.website.com/img/desktop/ios/icon-iphone.png
代替。所以我怀疑是 ProxyHTMLURLMap
的问题。
最佳答案
你们很亲密。我正在为那些正在搜索并偶然发现这篇文章的人发布我的答案。您将需要使用 Apache2 >= 2.4.17 来使用这个和几个启用的 mods(proxy、ssl、proxy_wstunnel、http、dir、defalte、env、headers、proxy_balancer、proxy_http、rewrite 我认为都是它们):
添加了一些新信息,现在以下配置可以让您观看预告片和听到电视节目主题音乐。
<Location>
部分 DEFINE plex_url 192.168.1.9
DEFINE plex_port 32400
DEFINE serv_name plex.domain.com
ServerTokens Prod
SSLStaplingCache "shmcb:${APACHE_LOG_DIR}/stapling-cache(150000)"
SSLSessionCache "shmcb:${APACHE_LOG_DIR}/ssl_scache(512000)"
SSLSessionCacheTimeout 300
### If you have Google's Mod PageSpeed, disable it ###
<IfModule mod_pagespeed_ap24.c>
ModPagespeed Off
</IfModule>
<VirtualHost *:80>
ServerName ${serv_name}
Redirect / https://plex.domain.com
ErrorLog ${APACHE_LOG_DIR}/plex.error.log
CustomLog ${APACHE_LOG_DIR}/plex.access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName ${serv_name}
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/plex.error.log
CustomLog ${APACHE_LOG_DIR}/plex.access.log combined
### Let's Encrypt Section ###
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
### Deny http1.0 requests ###
Protocols h2 http/1.1
### Harden Security ###
ProxyRequests Off
ProxyPreserveHost On
ProxyTimeout 600
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
ServerSignature Off
SSLCompression Off
SSLUseStapling On
SSLStaplingResponderTimeout 20
SSLStaplingReturnResponderErrors Off
SSLSessionTickets Off
### Add headers ###
RequestHeader set X-Forwarded-Proto 'https' env=HTTPS
Header always set Strict-Transport-Security "max-age=15552000;"
Header always set X-Content-Type-Options nosniff
Header always set X-Robots-Tag none
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "same-origin"
Header always set Permissions-Policy "geolocation=(self), midi=(self), sync-xhr=(self), microphone=(self), camera=(self), magnetometer=(self), gyroscope=(self), fullscreen=(self), payment=(self)"
### Content Security Policy for the overly paranoid - may break with Plex server updates (works with server version 1.21.3.4046 and 1.21.3.4021) ###
Header always set Content-Security-Policy "default-src 'none'; base-uri 'self' ${serv_name}; font-src 'self' data: ${serv_name}; media-src 'self' data: blob: ${serv_name} https://*.plex.direct:32400 https://video.internetvideoarchive.net https://*.cloudfront.net; script-src 'self' 'unsafe-inline' 'unsafe-eval' domain.com ${serv_name}; style-src 'self' 'unsafe-inline' ${serv_name}; img-src 'self' data: blob: https: ${serv_name}; worker-src * blob:; frame-src 'self'; connect-src 'self' https: domain.com ${serv_name} wss://*.plex.direct:32400 wss://pubsub.plex.tv; object-src 'self' ${serv_name}; frame-ancestors 'self' domain.com ${serv_name}; form-action 'self' ${serv_name}; manifest-src 'self' ${serv_name}; script-src-elem 'self' 'unsafe-inline' domain.com ${serv_name} www.gstatic.com"
### Add secure ciphers ###
SSLCipherSuite TLS-CHACHA20-POLY1305-SHA256:TLS-AES-256-GCM-SHA384:TLS-AES-128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
### Only enable TLSv1.2 and TLSv1.3 ###
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
### Tell clients to use server defined ciphers and orders ###
SSLHonorCipherOrder On
### If path is for Let's Encrypt, don't proxy ###
ProxyPassMatch ^/.well-known !
### Plex Specific Section ###
## Plex has A LOT of javascript, xml and html. This helps a lot, but if it causes playback issues with devices, disable this section
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
## Proxy all web traffic here ##
<Location />
ProxyPass http://${plex_url}:${plex_port}/
ProxyPassReverse http://${plex_url}:${plex_port}/
</Location>
## Proxy all websocket requests here ##
<Location /:/>
ProxyPass wss://${plex_url}:${plex_port}/:/
ProxyPassReverse wss://${plex_url}:${plex_port}/:/
</Location>
### Don't know if we still need this ###
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
#RewriteEngine on
#RewriteCond %{REQUEST_URI} !^/web
#RewriteCond %{HTTP:X-Plex-Device} ^$
#RewriteCond %{REQUEST_METHOD} !^(OPTIONS)$
#RewriteCond %{QUERY_STRING} (^|&)X-Plex-Device=(&|$) [OR]
#RewriteCond %{QUERY_STRING} !(^|&)X-Plex-Device=
#RewriteRule ^/$ /web/$1 [R,L]
</VirtualHost>
DEFINE plex_url 127.0.0.1
DEFINE plex_port 32400
DEFINE public_url subdomain.plex.tv
DEFINE email admin@subdomain.plex.tv
ServerTokens Prod
SSLStaplingCache "shmcb:${APACHE_LOG_DIR}/stapling-cache(150000)"
SSLSessionCache "shmcb:${APACHE_LOG_DIR}/ssl_scache(512000)"
SSLSessionCacheTimeout 300
### If you have Google's Mod PageSpeed, disable it
#ModPagespeed Off
<VirtualHost *:80>
ServerName ${public_url}
DocumentRoot /var/www/offline
ServerAdmin ${email}
RewriteEngine on
RewriteCond %{SERVER_NAME} =${public_url}
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName ${public_url}
DocumentRoot /var/www/offline
ServerAdmin ${email}
ErrorLog ${APACHE_LOG_DIR}/${public_url}.error.log
CustomLog ${APACHE_LOG_DIR}/${public_url}.access.log combined
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/${public_url}/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/${public_url}/privkey.pem
#Include /etc/letsencrypt/options-ssl-apache.conf
### Forbid the http1.0 protocol ###
Protocols h2 http/1.1
#Options -Includes -ExecCGI
#LimitRequestBody 512000
#FileETag None
#TraceEnable off
Timeout 360
ProxyRequests Off
ProxyPreserveHost On
ProxyTimeout 600
ProxyReceiveBufferSize 4096
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
ServerSignature Off
SSLCompression Off
SSLUseStapling On
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors Off
SSLSessionTickets Off
RequestHeader set X-Forwarded-Proto 'https' env=HTTPS
Header always set Strict-Transport-Security "max-age=15552000; preload"
Header always set X-Content-Type-Options nosniff
Header always set X-Robots-Tag none
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Content-Security-Policy "default-src 'self' https:; font-src 'self' data: ${plex_url} ${public_url}; media-src 'self' blob: data: https: ${plex_url} ${public_url} *.plex.direct *.plex.tv plex.tv; script-src 'self' 'unsafe-inline' 'unsafe-eval' ${plex_url} ${public_url} plex.tv *.plex.tv gstatic.com *.gstatic.com *.plex.direct; style-src 'self' ${plex_url} ${public_url} *.plex.direct; img-src 'self' data: blob: ${plex_url} ${public_url} plex.tv *.plex.tv *.plex.direct; worker-src *; frame-src 'none'; connect-src 'self' wss: https: ${plex_url} ${public_url} plex.tv *.plex.direct *.plex.tv;"
## If you want to be safer, remove the 'unsafe-inline' 'unsafe-eval' from above and use Chrome to get the sha-256 sums and input below (below was for Server version: 1.16.5.1488; Web version: 3.108.2)
#Header always set Content-Security-Policy "default-src 'self' https:; font-src 'self' data: ${plex_url} ${public_url}; media-src 'self' blob: data: https: ${plex_url} ${public_url} *.plex.direct *.plex.tv plex.tv; script-src 'self' 'sha256-8yKKbip2qr14RHV8H1qDEbRAm9Mmf5ePeQh+wB5pMCw=' 'sha256-pKO/nNgeauDINvYfxdygP3mGssdVQRpRNxaF7uPRoGM=' 'sha256-mrLkgfrqAhdxc2TvIODT0I7QtvuQLMS9AgtfLL9eMXo=' ${plex_url} ${public_url} plex.tv *.plex.tv gstatic.com *.gstatic.com *.plex.direct; style-src 'self' ${plex_url} ${public_url} *.plex.direct; img-src 'self' data: blob: ${plex_url} ${public_url} plex.tv *.plex.tv *.plex.direct; worker-src *; frame-src 'none'; connect-src 'self' wss: https: ${plex_url} ${public_url} plex.tv *.plex.direct *.plex.tv;"
Header always set Feature-Policy "geolocation 'self'; midi 'self'; sync-xhr 'self'; microphone 'self'; camera 'self'; magnetometer 'self'; gyroscope 'self'; speaker 'self'; fullscreen 'self'; payment 'self'"
### Use next two for very secure connections ###
SSLHonorCipherOrder On
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
### Use next two for secure connections and supports more endpoints ###
#SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
#SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
### Actually proxy the traffic and really the only important part ###
ProxyPass / http://${plex_url}:${plex_port}/
ProxyPassReverse / http://${plex_url}:${plex_port}/
ProxyPass /:/ ws://${plex_url}:${plex_port}/:/
ProxyPassReverse /:/ ws://${plex_url}:${plex_port}/:/
ProxyPass /:/ wss://${plex_url}:${plex_port}/:/
ProxyPassReverse /:/ wss://${plex_url}:${plex_port}/:/
LimitRequestBody 512000
FileETag None
TraceEnable off
#Header edit Set-Cookie ^(.*)$ ;HttpOnly;Secure
Timeout 60
<Location /:/websockets/notifications>
ProxyPass wss://${plex_url}:${plex_port}/:/websockets/notifications
ProxyPassReverse wss://${plex_url}:${plex_port}/:/websockets/notifications
</Location>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{HTTP:X-Plex-Device} ^$
RewriteCond %{REQUEST_METHOD} !^(OPTIONS)$
RewriteCond %{QUERY_STRING} (^|&)X-Plex-Device=(&|$) [OR]
RewriteCond %{QUERY_STRING} !(^|&)X-Plex-Device=
RewriteRule ^/$ /web/$1 [R,L]
</VirtualHost>
DEFINE plex_url 192.168.1.22
DEFINE plex_port 32400
DEFINE serv_name plex.domain.com
ServerTokens Prod
<VirtualHost *:80>
ServerName ${serv_name}
DocumentRoot /var/www/html
ServerAdmin aw@hell.no
ErrorLog ${APACHE_LOG_DIR}/${serv_name}.error.log
CustomLog ${APACHE_LOG_DIR}/${serv_name}.access.log combined
Options -Includes -ExecCGI
### Deny http1.0 requests ###
RewriteEngine On
RewriteCond %{SERVER_PROTOCOL} ^HTTP/1\.0$
#RewriteCond %{REQUEST_URI} !^/404/$
RewriteRule ^ - [F]
### Plex Specific Section ###
ProxyPass / http://${plex_url}:${plex_port}/
ProxyPassReverse / http://${plex_url}:${plex_port}/
ProxyPass /:/ ws://${plex_url}:${plex_port}/:/
ProxyPassReverse /:/ ws://${plex_url}:${plex_port}/:/
ProxyPass /:/ wss://${plex_url}:${plex_port}/:/
ProxyPassReverse /:/ wss://${plex_url}:${plex_port}/:/
LimitRequestBody 512000
FileETag None
TraceEnable off
#Header edit Set-Cookie ^(.*)$ ;HttpOnly;Secure
Timeout 60
<Location /:/websockets/notifications>
ProxyPass ws://${plex_url}:${plex_port}/:/websockets/notifications
ProxyPassReverse ws://${plex_url}:${plex_port}/:/websockets/notifications
</Location>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{HTTP:X-Plex-Device} ^$
RewriteCond %{REQUEST_METHOD} !^(OPTIONS)$
RewriteCond %{QUERY_STRING} (^|&)X-Plex-Device=(&|$) [OR]
RewriteCond %{QUERY_STRING} !(^|&)X-Plex-Device=
RewriteRule ^/$ /web/$1 [R,L]
</VirtualHost>
需要此设置,但用于 nginx ?
关于apache - 使用Apache作为反向代理访问子域下的Plex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40291126/
我完全不同意配置代理来检查我正在开发的应用程序的 HTTP(S) 流量。我试过运行 Fiddler2 和 Charles Web Proxy,它们都在 127.0.0.1:888 上运行,并使用以下参
我有一个 AWS 环境,其中有几个实例没有预安装 SSM 代理,也没有 key 对,有没有办法在不使用 SSH 登录我的实例的情况下安装 SSM 代理? 在此先感谢您的帮助! 最佳答案 没有。这是一个
在本教程中,您将借助示例了解 JavaScript 代理。 在 JavaScript 中,proxy(代理对象)用于包装对象并将各种操作重新定义到对象中,例如读取、插入、验证等。代理允许您向对
我有一个基于 Martini 的小型应用程序,但遇到了一个我无法解决的问题。 我想添加一个应用程序功能,允许用户从第三个服务器获取文件,并在 HTTP header 中进行一些更改。某种代理。这些文件
结构对比 讲实话,博主当初学习完整设计模式时,这三种设计模式单独摘哪一种都是十分清晰和明确的,但是随着模式种类的增加,在实际使用的时候竟然会出现恍惚,例如读开源代码时,遇到不以模式命名规范的代码时,
我正在尝试代理运行 ELK 的后端服务器。这是我的环境信息: root@proxy:~# root@proxy:~# cat /etc/*release DISTRIB_ID=Ubuntu DISTR
我需要为我的 java 应用程序编写一个代理,它在每个数组创建时执行一些特定的操作。到目前为止,我无法找到在此事件上运行我的代码的任何方法。 java.lang.instrument.ClassFil
PHP 代理如何工作? 我希望制作一个类似于其他 php 代理的小脚本 但是它实际上是如何工作的呢? 最佳答案 我正在考虑一个 PHP 代理,用于绕过 AJAX Sane Origin 策略。如果您需
我有一个 Electron 应用程序,试图通过该应用程序从同一网络调用url,但是出于安全考虑,我考虑了使用代理的想法。 function createWindow () { const mai
我有 1 台计算机,安装了 1 个网卡。网卡有 10 个 IP 地址分配给它。我在那里运行了一个 Windows 桌面应用程序。该应用程序基本上是一个调用 1 个特定网站的网络浏览器。 我想要实现的是
我想将 Burp 配置为我的 java 代码的代理,以查看请求和响应。Burp 作为 Web 浏览器之间的代理可以很好地工作,但它不适用于 Java 应用程序。 我已经在代码中添加了这样的行: Web
据我所知,在Spring AOP中,当我们想要拦截某些方法调用时,我们会配置一个具有与所需方法调用相匹配的切入点配置的Aspect。也就是说,我们在Aspect端配置拦截。 有没有一种方法可以完全从相
这可能是一个常见问题,但是:我有一个正在向 发出请求的应用程序elldmess.cz/api/... 但是这个api已经没有了。 现在我想要“东西”,即 catch 对 elldmess.cz/api
我正在尝试在 Android 中创建代理,但我必须使用套接字。我已经阅读了很多教程并提出了以下代码。不幸的是,浏览器似乎没有获得任何数据,一段时间后它显示标准网页,说网页不可用。可能是什么原因?感谢您
我在使用此代码时遇到了一些问题,具体取决于我使用的浏览器,有些 URL 在 IE 中显示正确,但在 Firefox 中显示为纯文本(例如 www.microsoft.es 在 IE 上看起来不错,但在
我正在尝试通过 urllib 获取一些 url 并通过我的代理进行 Mechanize 。 使用 mechanize 我尝试以下操作: from mechanize import Browser im
我安装了一个嵌入式设备(光伏转换器),它提供了一个正常的 http Web 界面(信息和设置)。该转换器具有用户身份验证,但只能通过 http 进行。出于安全考虑,我不想将服务器直接发布到互联网上。在
我正在搜索有关如何使用支持 HTTPS 的 Ruby 编写代理的一些示例。我有一个使用 Webricks HTTPProxyServer 实现的简单代理,但我注意到,HTTPS 流量只是隧道传输(它应
我的一位客户刚收到他选择的开发商订购的软件,让我看一下并准备托管程序。 这是一个 Java (jar) 应用程序,到目前为止一切顺利......但我看到了一些可疑的东西,软件每隔 60 分钟左右连接到
我试图在 C# 中创建一个 HTTPS 代理服务器。这里有人发布了解决方案: string host = "encrypted.google.com"; string
我是一名优秀的程序员,十分优秀!