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' |
import { useUserContext } from '../../contexts/UserContext' |
||||||
|
|
||||||
|
type Credentials = { |
||||||
|
username: string |
||||||
|
password: string |
||||||
|
} |
||||||
|
|
||||||
export const Login = () => { |
export const Login = () => { |
||||||
const { handleLogin } = useUserContext() |
const { handleLogin } = useUserContext() |
||||||
|
|
||||||
const [username, setUsername] = useState('') |
const [form] = useForm<Credentials>() |
||||||
const [password, setPassword] = useState('') |
|
||||||
|
|
||||||
const handleSubmit = (e: FormEvent) => { |
|
||||||
e.preventDefault() |
|
||||||
|
|
||||||
|
const handleSubmit = ({ username, password }: Credentials) => { |
||||||
handleLogin(username, password) |
handleLogin(username, password) |
||||||
} |
} |
||||||
|
|
||||||
return ( |
return ( |
||||||
<form onSubmit={handleSubmit}> |
<Form form={form} onFinish={handleSubmit}> |
||||||
<input |
<Form.Item label="username" name="username"> |
||||||
onChange={(e) => setUsername(e.target.value)} |
<Input /> |
||||||
type="text" |
</Form.Item> |
||||||
value={username} |
<Form.Item label="password" name="password"> |
||||||
/> |
<Input type="password" /> |
||||||
<input |
</Form.Item> |
||||||
onChange={(e) => setPassword(e.target.value)} |
<Button type="primary" htmlType="submit"> |
||||||
type="text" |
Login! |
||||||
value={password} |
</Button> |
||||||
/> |
</Form> |
||||||
<button type="submit">Login!</button> |
|
||||||
</form> |
|
||||||
) |
) |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue