GOLANG- nginx reverse proxy configuration port configuration domain

/Etc/nginx/nginx.conf configuration file

#   nformation on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   300;
    types_hash_max_size 2048;
    # 配置nginx上传文件最大限制
    client_max_body_size 50m;

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

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
       # root         /usr/share/nginx/html;

        root         /wwwroot;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

#	location ~ .php$ {
#  	  root   /wwwroot;
# 	  fastcgi_pass 127.0.0.1:9000;
# 	  fastcgi_index index.php;
#	  fastcgi_param SCRIPT_FILENAME /wwwroot$fastcgi_script_name;
#	  fastcgi_param PHP_INFO $1;
#	  include  fastcgi_params;
#	}

    }
}



New /etc/nginx/conf.d/doc.haimait.conf file

Dockhamatkchonfa

server {
  listen 80;
  server_name  doc.haimait.com;

  access_log  /var/log/nginx/doc.haimait.access.log;
  error_log  /var/log/nginx/doc.haimait.error.log;
  client_max_body_size 10m;
  location ~/(.well-known/pki-valtidation) {
      root /usr/share/nginx/html;
  }
  location / {
 #     add_header Access-Control-Allow-Origin *;
 #     add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
 #     add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
      proxy_pass  http://127.0.0.1:8811;
      proxy_redirect     off;
      proxy_set_header   Host             $host;
      proxy_set_header   X-Real-IP        $remote_addr;
      proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
      proxy_max_temp_file_size 0;
      proxy_connect_timeout      90;
      proxy_send_timeout         300;
      proxy_read_timeout         300;
      proxy_buffer_size          4k;
      proxy_buffers              4 32k;
      proxy_busy_buffers_size    64k;
      proxy_temp_file_write_size 64k;
      }
  location ~ ^/lovebook/ {
 #     add_header Access-Control-Allow-Origin *;
 #     add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
 #     add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
      proxy_pass  http://127.0.0.1:8844;
      proxy_redirect     off;
      proxy_set_header   Host             $host;
      proxy_set_header   X-Real-IP        $remote_addr;
      proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
      proxy_max_temp_file_size 0;
      proxy_connect_timeout      90;
      proxy_send_timeout         300;
      proxy_read_timeout         300;
      proxy_buffer_size          4k;
      proxy_buffers              4 32k;
      proxy_busy_buffers_size    64k;
      proxy_temp_file_write_size 64k;
      }
}


server {
   #listen       443 ssl;
   #server_name  test2.haimait.com;


   #ssl_certificate /etc/letsencrypt/live/test2.haimait.com/fullchain.pem;
   #ssl_certificate_key /etc/letsencrypt/live/test2.haimait.com/privkey.pem;
   #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   #ssl_prefer_server_ciphers on;
   #ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

location / {
#      add_header Access-Control-Allow-Origin *;
#      add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
#      add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
      proxy_pass  http://127.0.0.1:8811;
      proxy_redirect     off;
      proxy_set_header   Host             $host;
      proxy_set_header   X-Real-IP        $remote_addr;
      proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
      proxy_max_temp_file_size 0;
      proxy_connect_timeout      90;
      proxy_send_timeout         300;
      proxy_read_timeout         300;
      proxy_buffer_size          4k;
      proxy_buffers              4 32k;
      proxy_busy_buffers_size    64k;
      proxy_temp_file_write_size 64k;
    }
location ~ ^/lovebook/ {
#     add_header Access-Control-Allow-Origin *;
#     add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
#     add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
      proxy_pass  http://127.0.0.1:8844;
      proxy_redirect     off;
      proxy_set_header   Host             $host;
      proxy_set_header   X-Real-IP        $remote_addr;
      proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
      proxy_max_temp_file_size 0;
      proxy_connect_timeout      90;
      proxy_send_timeout         300;
      proxy_read_timeout         300;
      proxy_buffer_size          4k;
      proxy_buffers              4 32k;
      proxy_busy_buffers_size    64k;
      proxy_temp_file_write_size 64k;
    }
}

Restart nginx Service

[root@iZ2ze505h9bgsbp83ct28pZ nginx]# pwd
/etc/nginx
[root@iZ2ze505h9bgsbp83ct28pZ nginx]# ls conf.d/
default.conf_bak  doc.haimait.conf  phpmyadmin.conf  test.haimait.conf  test.haimait.conf_bak
[root@iZ2ze505h9bgsbp83ct28pZ nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@iZ2ze505h9bgsbp83ct28pZ nginx]# nginx -s reload

Resolve their domain name to the public network ip server

It does not own Baidu

At this point you have successfully configured the

Online Address:

http://doc.haimait.com/

Guess you like

Origin www.cnblogs.com/haima/p/12596118.html