将Apache2配置更改为Nginx配置?

我的服务器上现在有2个端口正在运行。

  1. 这是主应用程序端口5455
  2. 套接字端口8433

我们正在将该Apache设置迁移到Nginx。 在Apache中,我们有2个conf文件1个用于应用程序服务器,1个用于套接字

我已经能够正确移动应用程序服务器,但是无法使套接字正常工作

<VirtualHost _default_:8443>
    ServerAdmin admin@abc.tech
    ServerName api.abc.tech

    DocumentRoot /var/www/api.abc.tech/socket

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined



    SSLEngine on
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full

   <Proxy *>
      Require all granted
   </Proxy>
RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
RewriteCond %{QUERY_STRING} transport=websocket    [NC]
RewriteRule /(.*)           ws://localhost:8000/$1 [P,L]

        ProxyPass /socket.io/ http://127.0.0.1:8000/socket.io/
        ProxyPassReverse /socket.io/ http://127.0.0.1:8000/socket.io/

  SSLCertificateFile      /etc/apache2/sites-available/api.abc.tech.crt
  SSLCertificateKeyFile /etc/apache2/sites-available/api.abc.tech.key
  <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
  </FilesMatch>
    <Directory /usr/lib/cgi-bin>
       SSLOptions +StdEnvVars
    </Directory>

  BrowserMatch "MSIE [2-6]" \
  nokeepalive ssl-unclean-shutdown \
  downgrade-1.0 force-response-1.0

</VirtualHost> 

我当前的Nginx文件如下

server {
    listen 8443;
    server_name _;

    location / {
        proxy_pass http://localhost:8443;
    }
}

server {
    listen 80 default_server;

    server_name _;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl default_server;

    ssl_certificate /etc/letsencrypt/live/api.abc.tech/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/api.abc.tech/privkey.pem;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name api.abc.tech;

    location / {

     proxy_set_header   X-Forwarded-For $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header   Host $http_host;
         proxy_set_header X-NginX-Proxy true;
     proxy_pass         http://localhost:5455;

        if ($request_method = 'OPTIONS') {
                add_header 'access-control-allow-origin' '*';
                add_header 'access-Control-Allow-Methods' 'GET,POST,OPTIONS';
                add_header 'access-Control-Allow-Headers' '*';
                add_header 'access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain; charset=utf-8';
                add_header 'Content-Length' 0;
                return 200;
            }
    }

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

因此当应用程序到达以下路线时

https://api.abc.tech:8443/socket.io/?EIO=3&transport=polling&t=MvOh2

它返回错误以下

Referrer Policy: no-referrer-when-downgrade

如果您需要任何其他信息,请随时询问

在此方面的任何帮助将不胜感激。

ygbyyy 回答:将Apache2配置更改为Nginx配置?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3126579.html

大家都在问