【问题标题】:Nginx configuration file update issueNginx 配置文件更新问题
【发布时间】:2021-12-15 11:09:32
【问题描述】:

以前我在我的 ubuntu VPS 服务器中使用域。但目前,我不想在此服务器中使用 domainSSL。我想使用端口 80 中的唯一 IP 地址访问此服务器。我的服务器在 Ubuntu VPS 和 Nginx 上运行。 我对 Nginx 非常 。我不明白在哪里更改我的配置文件。我的 Nginx 配置如下。谁能帮我更新我的配置文件?

upstream app_server {
    server unix:/home/project_folder/run/gunicorn.sock fail_timeout=0;
}

server {

    # add here the ip address of your server
    # or a domain pointing to that ip (like example.com or www.example.com)
    server_name domain.com www.domain.com;

    keepalive_timeout 180;
    client_max_body_size 4G;

    proxy_connect_timeout 300s;
    proxy_read_timeout 300s;

    access_log /home/project_folder/logs/nginx-access.log;
    error_log /home/project_folder/logs/nginx-error.log;

    location /static/ {
        alias /home/project_folder/static_in_env/static_root/;
    }

    location /media/ {
        alias /home/project_folder/static_in_env/media_root/;
    }

    # checks for static file, if not found proxy to app
    location / {
        try_files $uri @proxy_to_app;
    }

    location @proxy_to_app {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://app_server;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}


server {
    if ($host = www.domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name domain.com www.domain.com;
    return 404; # managed by Certbot
}

感谢您宝贵的时间。

【问题讨论】:

    标签: ubuntu nginx server


    【解决方案1】:

    请将这两行从server_name domain.com www.domain.com;改为server_name Your IP Address;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-03
      • 1970-01-01
      • 2012-03-17
      • 2012-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多