微信小程序需要服务器要有域名,不能有端口,但是我还有一个WebSocket的wss协议路径需要填,都是后台的
user www www; worker_processes auto; error_log /www/wwwlogs/nginx_error.log crit; pid /www/server/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; multi_accept on; } http { include mime.types; #include luawaf.conf; include proxy.conf; default_type application/octet-stream; server_names_hash_bucket_size 512; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_name zone=perserver:10m; server_tokens off; access_log off; server { listen 443 ssl; server_name www.xxx.com; #配置证书的路径 ssl_certificate keys/5408289_wdestian0918.icu.pem; ssl_certificate_key keys/5408289_wdestian0918.icu.key; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; # 普通的https请求 location / { #配置转发到10086端口 proxy_pass http://wdestian0918.icu:10086; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; } # WebSocket 请求 location /wx { proxy_pass http://wdestian0918.icu:10086; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } include /www/server/panel/vhost/nginx/*.conf; }
访问时,通过https://wdestian0918.icu访问,https://wdetians0918.icu/根路径访问后台,https://wdetian0918.icu/wx 访问websocket
虽然再同一台服务器,但是如果使用nginx 配置10086 为前端项目,那么springboot用不了10086端口了,被占用了,这样只能开另外一个端口,就跨端口了。
解决:在server中转发,一个server就会占用一个端口
server{ listen 7200; server_name xupt-acat-interview-sign-up:7200; location / { root /home/acat/ACAT/acat_client; index index.html;# acat_client目录下index.html页面 } location /acat_sign { alias /home/acat/ACAT/acat_sign ; index index.html; } location /stu { proxy_pass http://localhost:7201; } }
访问请求:ip:7200/ 访问根目录下项目,ip:7200/acat_sign访问acat_sign下项目,
前端项目内,请求后台格式 ip:7200/stu nginx会转发到本机7201端口下的项目。
就是配置多个server
我的问题是
ping: smtp.qq.com: Temporary failure in name resolution 这个就是解析不了域名
解决方法:Temporary failure in name resolution(域名解析暂时失败)解决方法
还有一个数据库问题,也记录一下
ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’ 修改数据库密码
我的需求是服务器 root权限我没有,我只能sudo mysql -uroot -p 登陆
而且数据库普通用户acat的密码我也不知道,但是可以登陆上去root用户。
SET PASSWORD FOR ‘username’@‘hostname’ = PASSWORD (‘newpwd’);
9、 root修改普通用户密码