配置文件/etc/nginx/nginx.conf:

配置文件/etc/nginx/nginx.conf:
map $http_connection $connection_upgrade {
    "~*Upgrade" $http_connection;
    default keep-alive;
}

server {
  listen        80;
  server_name _;
  location / {
      proxy_pass         http://localhost:8080;
      proxy_http_version 1.1;
      proxy_set_header   Upgrade $http_upgrade;
      proxy_set_header   Connection $connection_upgrade;
      proxy_set_header   Host $host;
      proxy_cache_bypass $http_upgrade;
      proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header   X-Forwarded-Proto $scheme;
  }
}

atchyuth417@yashwanthi:~$ sudo nginx -T nginx:配置文件 /etc/nginx/nginx.conf 语法正确 nginx:配置文件 /etc/nginx/nginx.conf 测试成功

配置文件/etc/nginx/nginx.conf:

用户 www-data;worker_processes 自动;pid /run/nginx.pid;包括 /etc/nginx/modules-enabled/*.conf;

事件 { worker_connections 768; # multi_accept on; }

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}

#邮件 {

# 请参阅示例身份验证脚本:

#http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript

#auth_http 本地主机/auth.php;

#pop3_capabilities“TOP”“用户”;

#imap_capabilities“IMAP4rev1”“UIDPLUS”;

服务器 {

听本地主机:110;

协议 pop3;

代理;

}

服务器 {

听本地主机:143;

协议 imap;

代理;

}

#}

配置文件/etc/nginx/modules-enabled/50-mod-http-geoip2.conf:

加载模块/ngx_http_geoip2_module.so;

配置文件/etc/nginx/modules-enabled/50-mod-http-image-filter.conf:

load_module模块/ngx_http_image_filter_module.so;

配置文件/etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:

load_module模块/ngx_http_xslt_filter_module.so;

配置文件/etc/nginx/modules-enabled/50-mod-mail.conf:

load_module模块/ngx_mail_module.so;

配置文件/etc/nginx/modules-enabled/50-mod-stream.conf:

load_module 模块/ngx_stream_module.so;

配置文件/etc/nginx/modules-enabled/70-mod-stream-geoip2.conf:

加载模块/ngx_stream_geoip2_module.so;

配置文件/etc/nginx/mime.types:

类型 { 文本/html html htm shtml; 文本/css css; 文本/xml xml; 图像/gif gif; 图像/jpeg jpeg jpg; 应用程序/javascript js; 应用程序/atom+xml atom; 应用程序/rss+xml rss;

text/mathml                           mml;
text/plain                            txt;
text/vnd.sun.j2me.app-descriptor      jad;
text/vnd.wap.wml                      wml;
text/x-component                      htc;

image/png                             png;
image/tiff                            tif tiff;
image/vnd.wap.wbmp                    wbmp;
image/x-icon                          ico;
image/x-jng                           jng;
image/x-ms-bmp                        bmp;
image/svg+xml                         svg svgz;
image/webp                            webp;

application/font-woff                 woff;
application/java-archive              jar war ear;
application/json                      json;
application/mac-binhex40              hqx;
application/msword                    doc;
application/pdf                       pdf;
application/postscript                ps eps ai;
application/rtf                       rtf;
application/vnd.apple.mpegurl         m3u8;
application/vnd.ms-excel              xls;
application/vnd.ms-fontobject         eot;
application/vnd.ms-powerpoint         ppt;
application/vnd.wap.wmlc              wmlc;
application/vnd.google-earth.kml+xml  kml;
application/vnd.google-earth.kmz      kmz;
application/x-7z-compressed           7z;
application/x-cocoa                   cco;
application/x-java-archive-diff       jardiff;
application/x-java-jnlp-file          jnlp;
application/x-makeself                run;
application/x-perl                    pl pm;
application/x-pilot                   prc pdb;
application/x-rar-compressed          rar;
application/x-redhat-package-manager  rpm;
application/x-sea                     sea;
application/x-shockwave-flash         swf;
application/x-stuffit                 sit;
application/x-tcl                     tcl tk;
application/x-x509-ca-cert            der pem crt;
application/x-xpinstall               xpi;
application/xhtml+xml                 xhtml;
application/xspf+xml                  xspf;
application/zip                       zip;

application/octet-stream              bin exe dll;
application/octet-stream              deb;
application/octet-stream              dmg;
application/octet-stream              iso img;
application/octet-stream              msi msp msm;

application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

audio/midi                            mid midi kar;
audio/mpeg                            mp3;
audio/ogg                             ogg;
audio/x-m4a                           m4a;
audio/x-realaudio                     ra;

video/3gpp                            3gpp 3gp;
video/mp2t                            ts;
video/mp4                             mp4;
video/mpeg                            mpeg mpg;
video/quicktime                       mov;
video/webm                            webm;
video/x-flv                           flv;
video/x-m4v                           m4v;
video/x-mng                           mng;
video/x-ms-asf                        asx asf;
video/x-ms-wmv                        wmv;
video/x-msvideo                       avi;

}

配置文件/etc/nginx/sites-enabled/default:

您应该查看以下 URL,以便获得扎实的理解

Nginx 配置文件,以充分释放 Nginx 的强大功能。

https://www.nginx.com/resources/wiki/start/

https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/

https://wiki.debian.org/Nginx/DirectoryStructure

在大多数情况下,管理员会从 sites-enabled/ 中删除此文件,并且

将其作为参考保留在可用的站点内,并将继续

由 nginx 包装团队更新。

此文件将自动加载其他提供的配置文件

Drupal 或 Wordpress 等应用程序。这些应用程序将

可以在具有该包名称的路径下使用,例如 /drupal8。

请参阅 /usr/share/doc/nginx-doc/examples/ 了解更详细的示例。

默认服务器配置

#服务器 {

听 80 默认服务器;

听[::]:80默认服务器;

    # 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;

根目录/var/www/html;

    # Add index.php to the list if you are using PHP

索引 index.html index.htm index.nginx-debian.html;

服务器名称 _;

地点 / {

            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.

尝试文件$uri $uri/ =404;

}

    # 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;
    #       # With php-cgi (or other tcp sockets):
    #       fastcgi_pass 127.0.0.1:9000;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}

#} 映射 $http_connection $connection_upgrade { “~*Upgrade” $http_connection; 默认保持活动; }

服务器 { 监听 80; 服务器名称 _; 位置 / { proxy_pass http://localhost:8080; proxy_http_version 1.1; proxy_set_header 升级 $http_upgrade; proxy_set_header 连接 $connection_upgrade; proxy_set_header 主机 $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

example.com 的虚拟主机配置

您可以将其移动到 sites-available/ 下的其他文件,并对其进行符号链接

到 sites-enabled/ 来启用它。

#服务器 {

听80;

听 [::]:80;

服务器名称 example.com;

根/var/www/example.com;

索引 索引.html;

地点 / {

尝试文件$uri $uri/ =404;

}

#}

相关内容