parent
46e58722d6
commit
b12692dc5f
11 changed files with 108 additions and 31 deletions
@ -0,0 +1,3 @@ |
||||
FROM nginx:1.14.2 |
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf |
@ -0,0 +1,5 @@ |
||||
#!/bin/sh |
||||
|
||||
cat /nginx.conf > /etc/nginx/nginx.conf |
||||
|
||||
exec "$@" |
@ -0,0 +1,49 @@ |
||||
worker_processes 1; |
||||
|
||||
events { worker_connections 1024; } |
||||
|
||||
http { |
||||
upstream client { |
||||
server frontend:3000; |
||||
} |
||||
|
||||
server { |
||||
listen 80; |
||||
error_log /var/log/nginx/error.log; |
||||
access_log /var/log/nginx/access.log; |
||||
client_max_body_size 10M; |
||||
|
||||
location / { |
||||
proxy_pass http://client; |
||||
proxy_set_header Host $host; |
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
proxy_set_header X-Real-IP $remote_addr; |
||||
proxy_set_header X-Forwarded-Proto $scheme; |
||||
proxy_set_header X-Forwarded-Ssl on; # Optional |
||||
proxy_set_header X-Forwarded-Port $server_port; |
||||
proxy_set_header X-Forwarded-Host $host; |
||||
# proxy_set_header X-Forwarded-Host $server_name; |
||||
} |
||||
|
||||
location /api { |
||||
proxy_pass http://server:8000; |
||||
rewrite ^/api(.*)$ $1 break; |
||||
} |
||||
|
||||
location /cable { |
||||
proxy_pass http://server:8000; |
||||
proxy_http_version 1.1; |
||||
proxy_set_header Upgrade $http_upgrade; |
||||
proxy_set_header Connection "upgrade"; |
||||
# rewrite ^/cable(.*)$ $1 break; |
||||
} |
||||
|
||||
location /socksjs-node { |
||||
proxy_pass http://server:8000; |
||||
proxy_http_version 1.1; |
||||
proxy_set_header Upgrade $http_upgrade; |
||||
proxy_set_header Connection "upgrade"; |
||||
# rewrite ^/cable(.*)$ $1 break; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8" /> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
||||
<title>Document</title> |
||||
</head> |
||||
<body></body> |
||||
</html> |
@ -1,31 +1,32 @@ |
||||
import { FormEvent, useState } from 'react' |
||||
import { Button, Form, Input } from 'antd' |
||||
import { useForm } from 'antd/lib/form/Form' |
||||
import { useUserContext } from '../../contexts/UserContext' |
||||
|
||||
type Credentials = { |
||||
username: string |
||||
password: string |
||||
} |
||||
|
||||
export const Login = () => { |
||||
const { handleLogin } = useUserContext() |
||||
|
||||
const [username, setUsername] = useState('') |
||||
const [password, setPassword] = useState('') |
||||
|
||||
const handleSubmit = (e: FormEvent) => { |
||||
e.preventDefault() |
||||
const [form] = useForm<Credentials>() |
||||
|
||||
const handleSubmit = ({ username, password }: Credentials) => { |
||||
handleLogin(username, password) |
||||
} |
||||
|
||||
return ( |
||||
<form onSubmit={handleSubmit}> |
||||
<input |
||||
onChange={(e) => setUsername(e.target.value)} |
||||
type="text" |
||||
value={username} |
||||
/> |
||||
<input |
||||
onChange={(e) => setPassword(e.target.value)} |
||||
type="text" |
||||
value={password} |
||||
/> |
||||
<button type="submit">Login!</button> |
||||
</form> |
||||
<Form form={form} onFinish={handleSubmit}> |
||||
<Form.Item label="username" name="username"> |
||||
<Input /> |
||||
</Form.Item> |
||||
<Form.Item label="password" name="password"> |
||||
<Input type="password" /> |
||||
</Form.Item> |
||||
<Button type="primary" htmlType="submit"> |
||||
Login! |
||||
</Button> |
||||
</Form> |
||||
) |
||||
} |
||||
|
Loading…
Reference in new issue