我不能连接到nginx网站本地与www,我怎么解决这个问题

qxsslcnc  于 2023-03-22  发布在  Nginx
关注(0)|答案(1)|浏览(135)

我想知道如何做到这一点,我需要帮助,请!!
我目前正在运行2与nginx网站,一个作为反向代理(在端口8080上运行)和一个443和8083定期。我需要能够连接到本地网站上运行的API.像“www.example.com”的东西www.domain.com/api/v2
问题是,我的网站强制https和www以使某些东西工作,所以我不能只托管本地服务器并使用http://192.168.1.99:8083连接到它,因为它重定向到https://www.192.168.1.99:8083并不工作。有什么方法可以添加异常或任何东西吗?或者通过本地PC连接到domain.com?这是我的配置,请帮助我

server {
    listen 80;
    listen [::]:80;
    server_name www.satiresmp.ca satiresmp.cat;
}
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    keepalive_timeout 70;

        server_name www.satiresmp.ca satiresmp.ca;
        ssl_certificate /etc/letsencrypt/live/www.satiresmp.ca/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/www.satiresmp.ca/privkey.pem;
        root /var/www/satiresmp.ca;

    index index.php index.html;
    http2_push_preload on;

    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options nosniff;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { allow all; log_not_found off; access_log off; }
    location ~ /\. { deny all; }
    location ~* /(?:uploads|files)/.*\.php$ { deny all; }
    location / { try_files $uri $uri/ /index.php?route=$uri&$args; }
    location ~*  \.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|svg|ttf|woff2)$ { expires 365d; log_not_found off; }
    location ~ ^/\.user\.ini { deny all; }
    location ~ /\.ht { deny all; }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html { root /usr/share/nginx/html; }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        include fastcgi_params;
        include snippets/fastcgi-php.conf;
    }
}

我试着使用反向代理,我试着运行一个单独的Web服务器,我试着只关闭强制https和www,但这打破了我的网站软件的一些东西(这不是一个选项),我重新安装认证这么多次,我实际上得到了www.example.com的速率限制satiresmp.ca,所以我不得不做www.satiresmp.ca

4dbbbstv

4dbbbstv1#

这就是造成这种情况的原因:

add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;";

它强制浏览器始终重定向到https。
您可以禁用它,或者在不需要时添加第二个服务器块。

相关问题