#sites-available/example.confLoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that# the server uses to identify itself. This is used when creating# redirection URLs. In the context of virtual hosts, the ServerName# specifies what hostname must appear in the request's Host: header to# match this virtual host. For the default virtual host (this file) this# value is not decisive as it is used as a last resort host regardless.# However, you must set it for any further virtual host explicitly.#ServerName www.example.com ServerAdmin sivan@localhost
# Para qbittorrent RewriteEngine on
RewriteRule ^/torrent$ "/torrent/$1"[R] ProxyPass /torrent/ http://127.0.0.1:8080/
ProxyPassReverse /torrent/ http://127.0.0.1:8080/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,# error, crit, alert, emerg.# It is also possible to configure the loglevel for particular# modules, e.g.#LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are# enabled or disabled at a global level, it is possible to# include a line for only one particular virtual host. For example the# following line enables the CGI configuration for this host only# after it has been globally disabled with "a2disconf".#Include conf-available/serve-cgi-bin.conf</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
启动服务
1
2
sudo a2ensite example.conf
sudo service apache2 restart
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
ServerName www.hfsurrogacy.com
ServerAdmin webmaster@hfsurrogacy.com
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<LocationMatch "/web">
ProxyPass http://127.0.0.1:10086/web upgrade=WebSocket
ProxyAddHeaders Off
ProxyPreserveHost On
RequestHeader set Host %{HTTP_HOST}s
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
</LocationMatch>
</VirtualHost>
阿里云ssl证书安装错误
根据阿里云的教程在Apache服务器上安装SSL证书 (aliyun.com)
1.在服务器上更新证书apache2会报错
(1)错误1:AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globa
在apache.conf最后添加如下:
server { listen 80 default_server; listen [::]:80 default_server;# SSL configuration## listen 443 ssl default_server;# listen [::]:443 ssl default_server;## Note: You should disable gzip for SSL traffic.# See: https://bugs.debian.org/773332## Read up on ssl_ciphers to ensure a secure configuration.# See: https://bugs.debian.org/765782## Self signed certs generated by the ssl-cert package# Don't use them in a production server!## include snippets/snakeoil.conf; root /var/www/html;# Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name _; location / {# First attempt to serve request as file, then# as directory, then fall back to displaying a 404. try_files $uri$uri/ =404;# support .htaccessif(-f $request_filename/index.html){ rewrite (.*)$1/index.html break;}if(-f $request_filename/index.php){ rewrite (.*)$1/index.php;}if(!-f $request_filename){ rewrite (.*) /index.php;}} location /login { proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;set$is_v2ray 0;if($http_upgrade="websocket"){set$is_v2ray 1;}if($is_v2ray= 1){# 仅当请求为 WebSocket 时才反代到 V2Ray proxy_pass http://127.0.0.1:10086;}if($is_v2ray= 0){# 否则显示正常网页 rewrite ^/(.*)$ /mask-page last;}}# pass PHP scripts to FastCGI server# location ~ \.php$ { include snippets/fastcgi-php.conf;# With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php7.4-fpm.sock;}}