nginx 怎样代理mysql
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx 怎样代理mysql相关的知识,希望对你有一定的参考价值。
参考技术A 你的问题说法有错误,mysql是不需要nginx代理的,nginx只是一个平台环境而已,mysql只是这个平台里面的一部分。你只需要在nginx里面把mysql安装好,然后启用mysql进程,这样你就可以操作你的mysql了 参考技术B http://www.th7.cn/db/mysql/201409/70348.shtml本回答被提问者采纳
Nginx 代理MySQL
docker-compose.yml
version: '2.0'
services:
nginx:
restart: always
image: nginx:1.13.9-alpine
ports:
- 63307:63306
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
nginx配置文件
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events
worker_connections 1024;
http
include /etc/nginx/mime.types;
default_type application/octet-stream;
#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;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
stream
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /var/log/nginx/access.log proxy;
upstream mysql_server
server 127.0.0.1:3306;
server
listen 63306;
proxy_pass mysql_server;
以上是关于nginx 怎样代理mysql的主要内容,如果未能解决你的问题,请参考以下文章